python51 css重点 1.选择器 2.布局

## 复习
```python
"""
1、html:
 标记语言:解释性,没有逻辑(有无效果)
 常用标签(指令<!...>、转义字符&...;、标签<英文数字->)
  h1~h6 p a img div span i b ul>li table>tr>th|td form>input|select(option)|textarea|button|label
 嵌套关系(架构):div完成主架构、span完成同行文本架构 -> 具体内容选取具体标签
 
2、css:
 标记语言:解释性,没有逻辑(有无效果)
 引入方式 (行间式、内联式、外联式)
 选择器:!important > 行间式 > id > class > 标签 > *
 学习三个方向:引入方式、选择器、具体样式
"""
```
 
## 今日内容
```python
"""
css:重点 - 选择器、布局
 高级选择器
 伪类选择器
 常用样式
 三种布局方式
"""
```
 
## form提交方式:了解
```python
"""
get: 不安全的提交数据,高效
post: 安全的提交数据,低效
前台都可以给后台提交数据,后台一定会给前台一个反馈结果
"""
```
 
## 选择器高级
```css
/*选择器高级:基础选择器的各种组合*/
/*1、群组选择器:控制多个*/
/*注:每一个选择器位,可以为id、class、标签、选择器组合*/
#h1, .p, .a {
    color: red;
}
/*2、后代(子代)选择器:控制一个标签,前方的都是修饰*/
body .div2 .p2 {  /*后代 空格,父子(孙)*/
    color: orange;
}
.div2 > div > .p2 {  /*子代 >,父子*/
    color: pink;
}
/*高级选择器通过权重(个数)区别优先级:*/
 
/*3、兄弟(相邻)选择器:控制一个标签,前方的都是修饰*/
.p3 ~ .i3 {   /*兄弟 ~,可相邻也可不相邻,但必须通过上方修饰下方*/
    color: greenyellow;
}
.div3 + .i3 {   /*相邻 +,必须相邻,但必须通过上方修饰下方*/
    color: green;
}
/* 高级选择器优先级
前提:多个选择器控制同一个标签
无限大于:id > class > 标签   eg:一个id选择器 高于 n和类与标签选择器的组合
种类相同:比个数 eg:两个先比较id的个数,谁多谁优先级高,相同再比较类,以此类推
个数相同:比顺序 eg:所有类型所有个数(id、类、标签)都相同,下方的起作用
高级选择器种类不影响优先级 eg:后代选择器、子代选择器、兄弟选择器...不会运行优先级
*/
```
 
html代码
  • 1.复习表单.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <a href="https://www.baidu.com/s?wd=柯基">百度搜索柯基</a>
     7 </head>
     8 <body>
     9 <form action="https://fanyi.baidu.com/v2transapi" method="post">
    10     <input type="text" name="query">
    11     <input type="hidden" name="from" value="zh">
    12     <input type="hidden" name="to" value="en">
    13     <!--<input type="hidden" name="sign" value="538559.840846">-->
    14     <input type="hidden" name="sign" value="551517.821612">
    15     <input type="hidden" name="token" value="6fe02fb7b29bfc48ab4972d0b010ee51">
    16     <!--<input type="hidden" name="BAIDUID" value="3402863A7097725B60EF0A50DDC45E4A:FG=1">-->
    17     <button type="submit">翻译</button>
    18 
    19     <p>
    20         <label for="aaa">信息</label>
    21         <input type="text" id="aaa">
    22     </p>
    23 </form>
    24 </body>
    25 </html>
    View Code
  • 2.选择器高级.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         body {
     8             font-size: 30px;
     9         }
    10 
    11         /*选择器高级:基础选择器的各种组合*/
    12 
    13         /*1、群组选择器:控制多个*/
    14         /*注:每一个选择器位,可以为id、class、标签、选择器组合*/
    15         #h1, .p, .a {
    16             color: red;
    17         }
    18 
    19         /*2、后代(子代)选择器:控制一个标签,前方的都是修饰*/
    20         body .div2 .p2 {  /*后代 空格,父子(孙)*/
    21             color: orange;
    22         }
    23         .div2 > div > .p2 {  /*子代 >,父子*/
    24             color: pink;
    25         }
    26         /*高级选择器通过权重(个数)区别优先级:*/
    27         /*
    28         无限大于:id > class > 标签
    29         种类相同:比个数
    30         个数相同:比顺序
    31         高级选择器种类不影响优先级
    32         */
    33 
    34 
    35         /*3、兄弟(相邻)选择器:控制一个标签,前方的都是修饰*/
    36         .p3 ~ .i3 {   /*兄弟 ~,可相邻也可不相邻,但必须通过上方修饰下方*/
    37             color: greenyellow;
    38         }
    39         .div3 + .i3 {   /*相邻 +,必须相邻,但必须通过上方修饰下方*/
    40             color: green;
    41         }
    42 
    43     ul{
    44         list-style: none;
    45     }
    46     </style>
    47 </head>
    48 <body>
    49 <ul type="" style="">
    50     <li>1</li>
    51     <li>1</li>
    52     <li>1</li>
    53 </ul>
    54     <i class="i3">iiii1</i>
    55     <p class="p3">pppp</p>
    56     <div class="div3">dddd</div>
    57     <i class="i3">iiii2</i>
    58 
    59     <hr>
    60 
    61     <p class="p2">
    62         单独的p
    63     </p>
    64     <div class="div2">
    65         <div class="div22" id="div22">
    66             <p class="p2">div的p</p>
    67         </div>
    68     </div>
    69 
    70 
    71     <hr>
    72     <h1 class="h1" id="h1">标题</h1>
    73     <p class="p">段落</p>
    74     <div>
    75         <a class="a" href="">链接</a>
    76     </div>
    77 </body>
    78 </html>
    View Code
  • 3.伪类选择器.html
  •  1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title>Title</title>
     6 
     7         <style>
     8             /*()内填的是编号,所以从1开始*/
     9             /*1.伪类选择器可以单独出现,相当于省略了统配*/
    10             /*2.:nth-child先匹配层级位置,再匹配标签*/
    11             /*3.:nth-of-type先匹配标签类型,再匹配层级位置*/
    12             i:nth-child(1) {
    13                  color: orange;
    14             }
    15             i:nth-child(4) {
    16                  color: red;
    17             }
    18 
    19             i:nth-of-type(1) {
    20                 color: brown;
    21             }
    22             i:nth-of-type(2) {
    23                 color: blue;
    24             }
    25         </style>
    26 
    27         <style>
    28             .box {
    29                 width: 150px;
    30             }
    31             .pp {
    32                 width: 50px;
    33                 height: 50px;
    34                 background-color: red;
    35                 border-radius: 50%;
    36                 float: left;
    37                 text-align: center;
    38                 line-height: 50px;
    39             }
    40 
    41             /* 2n偶数  2n-1|2n+1奇数  3n最后一列  3n+1|3n-2第一列 3n-1中间列*/
    42             .pp:nth-child(3n-1) {
    43                 color: orange;
    44             }
    45 
    46             /*伪类选择器影响优先级,伪类就相当于class*/
    47             .a1.a2 {
    48                 color: red;
    49             }
    50             .a1:nth-child(1) {
    51                 color: orange;
    52             }
    53             /*id > class=:nth- > 标签*/
    54         </style>
    55 
    56         <style>
    57             /*属性选择器*/
    58             p[a] {
    59                 color: crimson;
    60             }
    61         </style>
    62     </head>
    63     <body>
    64 
    65         <a class="a1 a2" href="">aaaaaaaaaaaaaa</a>
    66 
    67         <hr>
    68         <!--p.pp.p${p$}*9-->
    69         <div class="box">
    70             <p class="pp p1" a>p1</p>
    71             <p class="pp p2" b>p2</p>
    72             <p class="pp p3">p3</p>
    73             <p class="pp p4">p4</p>
    74             <p class="pp p5">p5</p>
    75             <p class="pp p6">p6</p>
    76             <p class="pp p7">p7</p>
    77             <p class="pp p8">p8</p>
    78             <p class="pp p9">p9</p>
    79         </div>
    80 
    81         <hr>
    82 
    83         <i class="i3">iiii1</i>
    84         <p class="p3">pppp</p>
    85         <div class="div3">dddd</div>
    86         <i class="i3">iiii2</i>
    87         <hr>
    88         <div>
    89             <i class="i3">iiii1</i>
    90             <p class="p3">pppp</p>
    91             <div class="div3">dddd</div>
    92             <i class="i3">iiii2</i>
    93         </div>
    94     </body>
    95 </html>
    View Code
  • 4.a标签的四大伪类.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6 
     7     <style>
     8         /*链接的初始状态*/
     9         a:link {
    10             color: deepskyblue;
    11         }
    12         /*链接的悬浮状态*/
    13         a:hover {
    14             /*cursor: wait;*/
    15             /*cursor: col-resize;*/
    16             cursor: pointer;
    17             color: blue;
    18         }
    19         /*链接的激活状态*/
    20         a:active {
    21             color: deeppink;
    22         }
    23 
    24         /**链接的已访问状态*/
    25         a:visited {
    26             color: yellow;
    27         }
    28 
    29     </style>
    30 
    31     <style>
    32         body {
    33             /*文本不能选择*/
    34             user-select: none;
    35         }
    36         /*普通标签都可以去使用 :hover :active */
    37         .btn {
    38             width: 80px;
    39             height: 38px;
    40             background-color: cornflowerblue;
    41 
    42             border-radius: 5px;
    43             text-align: center;
    44             line-height: 38px;
    45             color: white;
    46         }
    47         .btn:hover {
    48             cursor: pointer;
    49             background-color: deepskyblue;
    50         }
    51         .btn:active {
    52             background-color: blue;
    53         }
    54     </style>
    55 </head>
    56 <body>
    57 <a href="https://www.baidu.com">aaaaaaaaaaaaaaaaaa</a>
    58 
    59 <div class="btn">按钮</div>
    60 
    61 
    62 </body>
    63 </html>
    View Code
  • 5.文本样式.html
  • 文本样式.html
     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>文本样式</title>
     6     <style>
     7         .div {
     8             width: 200px;
     9             height: 200px;
    10             background-color: orange;
    11         }
    12 
    13         .div {
    14             /*字体大小: 最小12px,还需要更小就更换字体库*/
    15             font-size: 30px;
    16 
    17             /*字体库(字族):字体, 备用1, ..., 备用n*/
    18             /*font-family: "STSong", "微软雅黑";*/
    19 
    20             /*字重: 100~900  bold normal lighter*/
    21             font-weight: lighter;
    22 
    23             /*字体颜色*/
    24             color: tomato;
    25 
    26             /*水平位置: left center right*/
    27             text-align: center;
    28 
    29             /*行高(垂直位置):默认文本在所在行高中垂直居中,要实现文本的垂直居中,让行高 = 容器高*/
    30             line-height: 200px;
    31 
    32             /*文本划线: underline line-through overline none*/
    33             text-decoration: underline;
    34         }
    35         a {
    36             text-decoration: none;
    37         }
    38         i {
    39             font-style: normal;
    40         }
    41     </style>
    42 </head>
    43 <body>
    44     <div class="div">文本</div>
    45     <a href="">aaaa</a>
    46     <i>dasdassad</i>
    47 </body>
    48 </html>
    View Code
  • 6.背景样式.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .bg {
     8             width: 300px;
     9             height: 300px;
    10             background-color: tomato;
    11         }
    12 
    13         .bg {
    14             /*背景颜色*/
    15             background-color: red;
    16             /*背景图片*/
    17             background-image: url("img/001.png");
    18             /*平铺: no-repeat repeat repeat-x repeat-y */
    19             background-repeat: no-repeat;
    20             /*背景定位: x轴(left center right) y轴(top center默认 bottom)*/
    21             /*background-position: right top;*/
    22             /*指定尺寸移动*/
    23             /*background-position: 100px 100px;*/
    24             /*反向移动*/
    25             background-position: 10px -10px;
    26         }
    27     </style>
    28 </head>
    29 <body>
    30     <div class="bg">12345</div>
    31 </body>
    32 </html>
    View Code
  • 7.背景样式案例.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         body {
     8             background-color: cornflowerblue;
     9         }
    10         .h1 {
    11             /* 1300px;*/
    12             /*height: 900px;*/
    13             width: 500px;
    14             height: 100px;
    15             background-color: tomato;
    16         }
    17         .h1 {
    18             background-image: url("img/bg.png");
    19             background-position: 0 -150px;
    20         }
    21         .h1:hover {
    22             background-position: 0 -250px;
    23         }
    24     </style>
    25     <style>
    26         .p1 {
    27             width: 155px;
    28             height: 48px;
    29             background-color: green;
    30             background-image: url("img/bg.png");
    31         }
    32         .p2 {
    33             width: 157px;
    34             height: 48px;
    35             background-color: green;
    36             background-image: url("img/bg.png");
    37             background-position-x: -155px;
    38         }
    39         .p1:hover, .p2:hover {
    40             background-position-y: -48px;
    41             cursor: pointer;
    42         }
    43         /*背景图片操作:就是更换背景图片的位置*/
    44     </style>
    45 </head>
    46 <body>
    47     <div class="h1">
    48 
    49     </div>
    50 
    51     <p class="p1"></p>
    52 
    53     <p class="p2"></p>
    54 </body>
    55 </html>
    View Code
  • 8.边界圆角.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .box {
     8             width: 400px;
     9             height: 200px;
    10             background-color: red;
    11         }
    12         .box {
    13             /*border-radius: 50%;*/
    14 
    15             /*左上是第一个角,顺时针编号,不足找对角,只有一个值同时控制4个角*/
    16             /*border-radius: 10px 20px 30px 40px;*/
    17             /*border-radius: 10px 50px 100px;*/
    18             /*border-radius: 10px 100px;*/
    19             /*border-radius: 100px;*/
    20 
    21             /*横向 / 纵向*/
    22             /*border-radius: 50% / 50px;*/
    23 
    24             /*横向1,2,3,4 / 纵向13,24*/
    25             /*border-radius: 10px 30px 50px 100px / 50px 100px;*/
    26 
    27             border-radius: 200px 200px 0 0 / 200px 200px 0 0;
    28         }
    29     </style>
    30 </head>
    31 <body>
    32     <div class="box"></div>
    33 </body>
    34 </html>
    View Code
     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .box {
     8             width: 400px;
     9             height: 200px;
    10             background-color: red;
    11         }
    12         .box {
    13             /*border-radius: 50%;*/
    14 
    15             /*左上是第一个角,顺时针编号,不足找对角,只有一个值同时控制4个角*/
    16             /*border-radius: 10px 20px 30px 40px;*/
    17             /*border-radius: 10px 50px 100px;*/
    18             /*border-radius: 10px 100px;*/
    19             /*border-radius: 100px;*/
    20 
    21             /*横向 / 纵向*/
    22             /*border-radius: 50% / 50px;*/
    23 
    24             /*横向1,2,3,4 / 纵向13,24*/
    25             /*border-radius: 10px 30px 50px 100px / 50px 100px;*/
    26 
    27             border-radius: 200px 200px 0 0 / 200px 200px 0 0;
    28         }
    29     </style>
    30 </head>
    31 <body>
    32     <div class="box"></div>
    33 </body>
    34 </html>
    View Code
  • 9.显示方式.html
  •  1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title></title>
     6 
     7     <style>
     8         /*
     9         block:1.可以手动设置宽高 2.自带换行 3.支持所有css样式
    10         inline:1.宽高只能由文本内容撑开,不能手动设置 2.不带换行 3.支持部分css样式
    11         inline-block:1.可以手动设置宽高 2.不带换行 3.支持所有css样式
    12         */
    13         /*
    14         嵌套关系
    15         block:可以嵌套block、inline、inline-block
    16             div、li搭架构的,可以任意嵌套     h1~h6、p 建议只嵌套inline,就是用来转文本的
    17         inline:只用来嵌套inline
    18             span、i、b、em、strong     a一般都会修改其display为block
    19         inline-block:不建议嵌套任何
    20             img input系统都设计成了单标签
    21         none:没有显示方式,就会在页面中隐藏
    22         */
    23         /*
    24         开发是:修改display的情况 - 要支持宽高,要更改位置(水平排列还是垂直排列)
    25         */
    26         div {
    27             display: block;
    28             width: 100px;
    29             height: 100px;
    30             background-color: red;
    31         }
    32         span {
    33             display: inline;
    34             width: 100px;
    35             height: 100px;
    36             background-color: orange;
    37         }
    38         owen {
    39             display: inline-block;
    40             width: 100px;
    41             height: 100px;
    42             background-color: pink;
    43         }
    44     </style>
    45     <style>
    46         a {
    47             display: block;
    48             width: 100px;
    49             /*height: 100px;*/
    50             /*透明色:transparent*/
    51             background-color: brown;
    52             border: 1px solid black;
    53         }
    54         img {
    55             width: 100px;
    56         }
    57         p {
    58             text-align: center;
    59         }
    60     </style>
    61 </head>
    62 <body>
    63     <!--div{divdivdiv}*2+span{spanspanspan}*2-->
    64     <div>divdivdiv</div>
    65     <div>divdivdiv</div>
    66     <span>spanspanspan</span>
    67     <span>spanspanspan</span>
    68     <owen>owenowenowen</owen>
    69     <owen>owenowenowen</owen>
    70 
    71     <a href="https://www.baidu.com">
    72         <img src="img/bd_logo.png" alt="">
    73         <p>前往百度</p>
    74     </a>
    75 </body>
    76 </html>
    View Code
  • 10.block的显示规则.html
  •  1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         /*display:
     8         不同的标签在页面中有不同的显示规则
     9         如有些是自带换行、有些同行显示、有些同行显示还支持宽高,这些不是标签的特性,而是标签的display属性值决定的
    10 
    11         完成复杂的布局和样式,标签的显示方式都采用 block
    12         a {
    13             display: block;
    14         }
    15         a可以任意嵌套其他标签,还可以设置宽高,还支持所有css样式,但是a不再同行显示了(block自带换行)
    16 
    17         如果解决block同行显示 => css布局
    18 
    19         */
    20 
    21         /*
    22         inline: 同行显示,不用去关宽高,不用额外操作
    23         inline-block: 同行显示, 一般会主动设置宽或高、设置宽,高会等比缩放,反之亦然
    24         有inline特性的标签,同行显示,但是有默认垂直对其方式vertical-align
    25         */
    26 
    27         /*
    28         block:默认显示规则
    29 
    30         宽继承父级,高由内容撑开
    31         */
    32         img {
    33             border: 1px solid black;
    34         }
    35         .img1 {
    36             width: 200px;
    37         }
    38         .img2 {
    39             height: 200px;
    40         }
    41         span, img {
    42             /*baseline基线 middle中线 top顶线*/
    43             vertical-align: middle;
    44         }
    45     </style>
    46     <style>
    47         div {
    48             height: 100px;
    49             border: 1px solid black;
    50             display: inline-block;
    51         }
    52         .d1 {
    53             width: 200px;
    54         }
    55         .d2 {
    56             width: 500px;
    57         }
    58         .d3 {
    59             width: 200px;
    60         }
    61     </style>
    62 </head>
    63 <body>
    64 <span>123</span>
    65 <span>456</span>
    66 <img class="img1" src="img/bd_logo.png" alt="">
    67 <img class="img2" src="img/bd_logo.png" alt="">
    68 <hr>
    69 <div class="d1"></div>
    70 <div class="d2"></div>
    71 <div class="d3"></div>
    72 
    73 </body>
    74 </html>
    View Code
  • 11.overflow属性.html
  •  1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         /*
     8         1、规定了标签的宽高,标签的内容超出范围
     9         2、规定了标签的宽高,标签内的子标签显示区域更大,超出范围
    10         如果让父级宽高限制内容和子集
    11         */
    12         .box {
    13             width: 200px;
    14             height: 200px;
    15             background-color: orange;
    16             /*内容超出,都会以 hidden 处理影藏,如果想显示全内容,采用子页面*/
    17             /*hidden:影藏超出内容  scroll:以滚动显示超出内容  auto:有超出内容才滚动显示*/
    18             overflow: scroll;
    19         }
    20         .sup {
    21             width: 200px;
    22             height: 200px;
    23             background-color: red;
    24             /*overflow: hidden;*/
    25         }
    26         .sub {
    27             width: 300px;
    28             height: 300px;
    29             background-color: pink;
    30         }
    31     </style>
    32 </head>
    33 <body>
    34     <div class="box">汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字汉字</div>
    35     <div class="sup">
    36         <div class="sub"></div>
    37     </div>
    38 </body>
    39 </html>
    View Code
  • 12.盒模型.html
  •  1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>盒模型</title>
     6     <style>
     7         .box {
     8             width: 200px;
     9             height: 200px;
    10             background-color: red;
    11         }
    12         /*盒模型:
    13         什么是盒模型:页面中的每一个标签都可以称之为一个盒子
    14         盒子的组成并发:外边距、边框、内边距、内容四部分组成,每部分都有独立区域
    15 
    16         外边距 - margin - 控制位置
    17         边框 - border - 控制边框
    18         内边距 - padding - 控制内容与边框的间距
    19         内容 - content(width*height) - 文本内容或子标签显示的区域
    20         */
    21         .box {
    22             /*padding: 50px;*/
    23         }
    24         .box {
    25             /*上右下左*/
    26             /*当要保证显示区域不变,内容往里偏移,增加padding、相应减少content*/
    27             padding: 20px 0 0 20px;
    28             width: 180px;
    29             height: 180px;
    30         }
    31         .box {
    32             /*border边框:宽度 、 样式 solid实现 dashed虚线 dotted点状线、 颜色*/
    33             border: 10px dotted black;
    34         }
    35         /*margin参考系:自身原有位置
    36         margin的left和top控制自身位置
    37         margin的right和bottom控制兄弟位置
    38         */
    39         .box {
    40             margin-left: 100px;
    41             margin-top: 100px;
    42         }
    43         .abc {
    44             width: 200px;
    45             height: 200px;
    46             background-color: orange;
    47             margin-top: 10px;
    48             margin-left: -1px;
    49         }
    50         .top, .bottom {
    51             width: 100px;
    52             height: 100px;
    53             background-color: pink;
    54         }
    55         .top {
    56             margin-bottom: -50px;
    57         }
    58         .bottom {
    59             background-color: tan;
    60         }
    61         /*盒模型布局的地位:盒模型用来完成超简单的布局要求,一般都是用来辅助其他布局,完成布局的微调*/
    62 
    63         .abc {
    64             /*上右下左*/
    65             /*margin: 10px 20px 30px 40px;*/
    66             /*快速居右*/
    67             /*margin-left: auto;*/
    68             /*快速居中*/
    69             /*margin-left: auto;*/
    70             /*margin-right: auto;*/
    71             margin: 0 auto;
    72         }
    73     </style>
    74 </head>
    75 <body>
    76     <div class="box">12345</div>
    77     <div class="abc"></div>
    78 
    79     <div class="top"></div>
    80     <div class="bottom"></div>
    81 </body>
    82 </html>
    View Code
  • 13.浮动布局.html
  •  1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .wrap {
     8             width: 150px;
     9             background-color: cornflowerblue;
    10             /*height: 200px;*/
    11         }
    12         .d {
    13             width: 50px;
    14             height: 50px;
    15             background-color: orange;
    16             border-radius: 50%;
    17         }
    18         /*浮动布局:不再撑开父级高度,但浮动受父级宽度影响*/
    19         .d {
    20             float: right;
    21         }
    22         /*如何让父级刚刚好包含所有子标签:清浮动 - 不是清除子标签的浮动效果,而是让父级获得一个刚好的高度*/
    23         .wrap:after {
    24             display: block;
    25             content: "";
    26             /*清浮动的关键*/
    27             clear: both;
    28         }
    29     </style>
    30 </head>
    31 <body>
    32     <div class="wrap">
    33         <div class="d d1">1</div>
    34         <div class="d d2">2</div>
    35         <div class="d d3">3</div>
    36         <div class="d d4"></div>
    37         <div class="d d5"></div>
    38         <div class="d d6"></div>
    39         <div class="d d7"></div>
    40         <div class="d d8"></div>
    41         <div class="d d9"></div>
    42 
    43     </div>
    44 </body>
    45 </html>
    View Code
 
 
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/llx--20190411/p/11116245.html