coderwhy
01_表格实现细线表格
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> h2 { text-align: center; }
table { border: 1px solid #666;
border-collapse: collapse;
margin: 20px auto; }
table tr:first-child { font-weight: 700; }
td { border: 1px solid #666; padding: 20px; } </style> </head> <body> <h2>影院电影放映列表</h2> <table> <tr> <td>单元格1</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> </table>
</body> </html>
|
text-align 用于设置元素内容在元素中的水平对齐方式,CSS属性定义行内内容(例如文字)如何相对它的块父元素对齐。
text-align并不控制块元素自己的对齐,只控制它的行内内容的对齐。
02_表格表格中其他元素
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> table { border: 1px solid #666;
border-collapse: collapse;
margin: 20px auto; }
caption { font-weight: 700; font-size: 25px;
margin-bottom: 20px; }
td, th { border: 1px solid #666; padding: 20px; text-align: center; } </style> </head> <body> <table> <caption>影院电影放映列表</caption> <thead> <tr> <th>单元格1</th> <th>单元格2</th> <th>单元格3</th> <th>单元格4</th> <th>单元格5</th> </tr> </thead> <tbody> <tr> <td>单元格1</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> </tbody> <tfoot> <tr> <td>页脚1</td> <td>页脚2</td> <td>页脚3</td> <td>页脚4</td> <td>页脚5</td> </tr> </tfoot> </table>
</body> </html>
|
03_表格单元格合并基本使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> table { border-collapse: collapse;
margin: 0 auto; }
td { border: 1px solid skyblue; padding: 20px;
text-align: center; } </style> </head> <body>
<table> <tr> <td colspan="2">单元格1</td> <td>单元格3</td> <td>单元格4</td> <td>单元格5</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> <td rowspan="2">单元格3</td> <td rowspan="2" colspan="2">单元格4</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> </tr> </table>
</body> </html>
|
04_表格单元格合并的练习
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> table { border-collapse: collapse;
margin: 0 auto; }
td { border: 1px solid skyblue;
padding: 6px 25px;
text-align: center; }
[colspan], [rowspan], tr:nth-child(2) { font-weight: 700; } </style> </head> <body> <table> <tr> <td colspan="6">课程表</td> </tr> <tr class="week"> <td></td> <td>星期一</td> <td>星期二</td> <td>星期三</td> <td>星期四</td> <td>星期五</td> </tr> <tr> <td rowspan="4">上午</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td rowspan="4">下午</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td rowspan="2">晚自习</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> <tr> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> <td>音乐</td> </tr> </table>
</body> </html>
|
05_表单表单提交相关的演练
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> /* body, ul { margin: 0; padding: 0; } */
ul { list-style: none; }
input, textarea { outline: none; }
textarea { resize: none; }
fieldset { width: 400px; }
input, textarea { outline: none; }
input:focus, textarea:focus { border-color: #4791ff; border-style: solid; } </style> </head> <body> <form action="http://www.baidu.com" method="POST" enctype="multipart/form-data">
<fieldset> <legend>必填信息</legend> <div> <label for="phone">手机:</label> <input type="text" maxlength="11" placeholder="请输入您的手机号" autofocus name="phone" tabindex="-1"> </div>
<div> <label for="password">密码:</label> <input type="password" id="password" name="password"> </div> <div> <label for="validate">验证码:</label> <input type="text" id="validate" name="code">
<input type="button" value="获取验证码" disabled> </div> </fieldset> <fieldset> <legend>选填信息</legend>
<div> <label for="photo">照片:</label> <input type="file" id="photo" name="photo"> </div> <div> <span>性别:</span> <label for="male">男</label> <input type="radio" name="sex" id="male" value="male" checked> <label for="female">女</label> <input type="radio" name="sex" id="female" value="female"> </div> <div> <span>爱好:</span> <label for="sing">唱歌</label> <input type="checkbox" name="hobbies" id="sing" value="sing" checked> <label for="dance">跳舞</label> <input type="checkbox" name="hobbies" id="dance" value="dance"> <label for="rap">rap</label> <input type="checkbox" name="hobbies" checked id="rap" value="rap"> <label for="basketball">篮球</label> <input type="checkbox" name="hobbies" id="basketball" value="basketball"> </div>
<div> <span>学历:</span> <select name="education" id="" multiple> <option value="0">小学</option> <option value="1">初中</option> <option value="2" selected>高中</option> <option value="3">大专</option> </select> </div>
<div> <label for="introduce">简介:</label> <textarea name="intro" cols="20" rows="5" id="introduce"></textarea> </div> </fieldset>
<input type="reset">
<input type="submit"> </form> </body> </html
|
06_邮箱列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> ul { list-style: none; padding: 0; margin: 0; }
a { text-decoration: none; color: #000; }
.email { width: 100px; border: 2px solid #999; text-align: center; }
.email:hover ul { display: block; }
/* .header:hover+ul { display: block; background-color: #f00; } */
.header { background-color: #999; color: #fff; }
.email ul { display: none; }
.email ul li a:hover { background-color: skyblue; }
.email ul li a { display: block; }
</style> </head> <body> <div class="email"> <div class="header">邮箱</div> <ul> <li><a href="#">QQ邮箱</a></li> <li><a href="#">163邮箱</a></li> <li><a href="#">139邮箱</a></li> </ul> </div>
<div class="product"> <ul class="list"> <li></li> </ul> </div>
</body> </html>
|
07_分页列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> ul { list-style: none; padding: 0; margin: 0; }
a { text-decoration: none; color: #0000cc; }
.page ul li { display: inline-block; }
.page ul li a { display: inline-block; width: 34px; height: 34px; border: 1px solid #e1e2e3;
font-size: 14px;
margin-right: 5px;
text-align: center; line-height: 34px; }
.page ul li a:hover { border: 1px solid #38f; background-color: #f2f8ff; }
.page .prev a, .page .next a { width: 88px; }
.page .active { width: 36px; height: 36px; line-height: 36px;
border: none; font-weight: 700; color: #000;
}
.page .active:hover { border: none; background-color: transparent; } .page ul li .active { border: 1px solid transparent; /* width: 36px; height: 36px; line-height: 36px; border: none; */ font-weight: 700; }
.page ul li .active:hover { border: 1px solid transparent; background-color: transparent; } </style> </head> <body>
<div class="page"> <ul> <li class="prev"><a href="#"><上一页</a></li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">5</a></li> <li><a href="#">6</a></li> <li><a class="active">7</a></li> <li><a href="#">8</a></li> <li><a href="#">9</a></li> <li><a href="#">10</a></li> <li class="next"><a href="#">下一页></a></li> </ul> </div>
</body> </html>
|
08_css-sprite京东练习
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style>
p, ul, body, h5 { margin: 0; padding: 0; }
ul { list-style: none; }
.wrap { width: 1000px; margin: 0 auto; }
.nav { height: 30px; background-color: #333; color: #fff; }
li, h5, p { display: inline-block; vertical-align: middle; }
.service ul li { margin-left: 12px; margin-right: 25px; }
.service ul li p { height: 42px; line-height: 42px;
font-size: 18px; color: #444; font-weight: 700;
margin-left: 3px; }
.service ul li h5 { width: 36px; height: 42px; text-indent: -999px; background-image: url("./img/jd_sprite_01.png"); }
.service ul li:nth-child(1) h5 { background-position: 0 -192px; }
.service ul li .kuai { background-position: -41px -192px; }
.service ul li .hao { background-position: -82px -192px; }
.service ul li .sheng { background-position: -123px -192px; }
</style> </head> <body> <div class="nav wrap"> <div class="left">左边的内容</div> <div class="right">右边的内容</div> </div> <div class="header wrap"> </div> <div class="footer wrap"></div>
<div class="service wrap"> <ul> <li> <h5 class="duo">多</h5> <p>品类齐全,轻松购物</p> </li> <li> <h5 class="kuai">快</h5> <p>多仓直发,极速配送</p> </li> <li> <h5 class="hao">好</h5> <p>正品行货,精致服务</p> </li> <li> <h5 class="sheng">省</h5> <p>天天低价,畅选无忧</p> </li> </ul> </div>
</body> </html>
|
CSS 的属性 vertical-align用来指定行内元素(inline)或表格单元格(table-cell)元素的垂直对齐方式。
vertical-align属性可被用于两种环境:
注意 vertical-align 只对行内元素、表格单元格元素生效:不能用它垂直对齐块级元素。
text-indent 属性能定义一个块元素首行文本内容之前的缩进量。
09_定位考拉侧面工具栏
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> ul { list-style: none; padding: 0; margin: 0; }
i { font-style: normal; }
a { text-decoration: none; color: #333; }
.aside-right { position: fixed; right: 60px; top: 100px; border: 1px solid #eaeaea; }
.aside-right ul li a { display: inline-block; width: 62px; height: 48px; padding: 12px 0 0; font-size: 12px; text-align: center; border-bottom: 1px solid #eaeaea; }
.aside-right ul li a:hover { color: #ff1e32; background-color: #f6f6f6; }
.aside-right ul li a.top { border-bottom: none; }
.aside-right ul a i { display: block; margin: 0 auto 3px; width: 20px; height: 20px; }
.aside-right ul .sign i { background-image: url("./img/icon-aside-right-signin.png"); } .aside-right ul .cart i { background-image: url("./img/icon-aside-right-cart.png"); }
.aside-right ul .app i { background-image: url("./img/icon-aside-right-phone.png"); }
.aside-right ul .top i { background-image: url("./img/icon-aside-right-top.png"); }
.aside-right ul .sign:hover i { background-image: url("./img/icon-aside-right-signin-active.png"); }
.aside-right ul .cart:hover i { background-image: url("./img/icon-aside-right-cart-active.png"); }
.aside-right ul .app:hover i { background-image: url("./img/icon-aside-right-phone-active.png"); }
.aside-right ul .top:hover i { background-image: url("./img/icon-aside-right-top-active.png"); } </style>
</head> <body> <div class="aside-right"> <ul> <li> <a class="sign" href=""> <i></i> <span>签到</span> </a> </li> <li> <a class="cart" href=""> <i></i> <span>购物车</span> </a> </li> <li> <a class="app" href=""> <i></i> <span>APP</span> </a> </li> <li> <a class="top" href=""> <i></i> <span>TOP</span> </a> </li> </ul> </div>
</body> </html>
|
10_定位考拉二维码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> body { font: 12px/1.5 Helvetica Neue,Helvetica,Arial,Hiragino Sans GB,\5FAE\8F6F\96C5\9ED1,tahoma,simsun,\5b8b\4f53; }
.phone { text-decoration: none; color: #333; position: relative; margin-left: 300px; }
.phone .code { position: absolute; top: 27px; left: 50%; transform: translate(-50%); padding: 5px 5px 0; border: 1px solid #eaeaea; display: none; }
.phone .code span { text-align: center; font-size: 14px; display: block; } .phone .code img { margin-bottom: 3px; }
.phone .code .arrow { position: absolute; top: -5px; left: 0; right: 0; margin: 0 auto;
width: 8px; height: 8px; background-color: #fff;
border-top: 1px solid #eaeaea; border-left: 1px solid #eaeaea; transform: rotate(45deg); } .phone>span:hover+.code { display: block; } .phone:hover .code { display: block; } </style> </head> <body> <a class="phone" href="#"> <span>手机考拉</span> <span class="code"> <span class="arrow"></span> <img src="./img/qrcode.png" alt=""> <span>下载APP</span> <span>领1000元新人礼包</span> </span> </a> </body> </html>
|
11_定位梦幻西游的大图
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> body { margin: 0; }
.box { overflow: hidden; min-width: 1000px; }
.box img { position: relative; left: -960px;
margin-left: 50%; } </style> </head> <body> <div class="box"> <img src="./img/mhxy.jpg" alt=""> </div>
</body> </html>
|
CSS 属性 translate 允许你单独声明平移变换,并独立于 transform属性。这在一些典型的用户界面上更好用,而且这样就无需在 transform 中声明该函数并记住转换函数的确切顺序了。
left和margin-left的百分比相对于包含块的宽度
translate的百分比相对于自己的
12_定位定位元素的居中
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .box { width: 1000px; height: 500px; background-color: #f00; position: relative; }
.inner { width: 100px; height: 100px; background-color: #ff0; position: absolute; left: 10px; right: 10px; margin: 0 auto;
top: 50%; transform: translate(0, -50%); } </style> </head> <body> <div class="box"> <div class="inner"></div> </div>
</body> </html>
|
CSS中left属性定义了定位元素的左外边距边界与其包含块左边界之间的偏移, 非定位元素设置此属性无效。
left的效果取决于元素的position属性:
- 当position设置为absolute或fixed时,left属性指定了定位元素左外边距边界与其包含块左边界之间的偏移。
- 当position设置为relative时,left属性指定了元素的左边界离开其正常位置的偏移。
- 当position设置为sticky时,如果元素在viewport里面,left属性的效果和position为relative等同;如果元素在viewport外面,left属性的效果和position为fixed等同。
- 当position设置为static时,left属性无效。
当left和right同时指定时,元素的位置会被重复指定。当容器是从左到右时,left的值会被优先设定;当容器是从右到左时,right的值会被优先设定。
13_定位考拉商品大图
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <link rel="stylesheet" href="../css/reset.css">
<style> ul { padding: 0; margin: 0; list-style: none; }
a { text-decoration: none; color: #333; }
img { vertical-align: middle; }
.beauty-left { position: relative; background-color: #f00; display: inline-block; }
.beauty-left ul { position: absolute; bottom: 30px; width: 285px;
text-align: justify; text-align-last: justify;
left: 0; right: 0; margin: 0 auto; }
.beauty-left ul li { display: inline-block; }
.beauty-left ul li a { display: inline-block; width: 80px; height: 40px; line-height: 40px; margin-top: 10px; font-size: 12px; text-align: center; text-align-last: center;
border: 1px solid #eaeaea; border-radius: 40px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); background-color: #fff; }
.beauty-left ul li a:hover { color: #ff1e32; } </style> </head> <body> <div class="beauty-left"> <a href="#"> <img src="./img/beauty-left-img.jpg" alt=""> </a> <ul> <li><a href="#">精致护肤</a></li> <li><a href="#">人气面膜</a></li> <li><a href="#">大牌彩妆</a></li> <li><a href="#">防晒修护</a></li> <li><a href="#">迷人香氛</a></li> <li><a href="#">面部精华</a></li> </ul> </div>
</body> </html>
|
14_绝对定位的演练
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .box1 { position: relative;
width: 500px; height: 500px; background-color: #f00; }
.box2 { position: absolute;
right: 0;
width: 300px; height: 300px; background-color: #0f0; }
a { position: absolute; top: 20px; right: 20px; } </style> </head> <body> <div class="box1"> <div class="box2"> <a href="">a元素</a> </div> </div>
</body> </html>
|
15_京东布局案例01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .container { width: 990px; height: 500px; background-color: #f00;
margin: 0 auto; }
.section { float: left; width: 490px; height: 300px; }
.section1 { background-color: #0f0; margin-right: 10px; }
.section2 { background-color: #00f; } </style> </head> <body> <div class="container"> <div class="section section1"></div> <div class="section section2"></div> </div>
</body> </html>
|
16_京东布局案例02
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .container { width: 990px; height: 500px; background-color: #f00;
margin: 0 auto; }
.wrap { margin-right: -10px; }
.section { float: left;
margin-top: 10px; width: 190px; height: 100px; background-color: #0f0;
margin-right: 10px; }
/* div .section:nth-child(5n) { margin-right: 0; } */
/* .section5, .section10 { margin-right: 0; } */
/* .section1, .section2, .section3, .section4, .section5 { margin-right: 10px; } */ </style> </head> <body> <div class="container"> <div class="wrap"> <div class="section section1"></div> <div class="section section2"></div> <div class="section section3"></div> <div class="section section4"></div> <div class="section section5"></div> <div class="section section6"></div> <div class="section section7"></div> <div class="section section8"></div> <div class="section section9"></div> <div class="section section10"></div> <div class="section section6"></div> <div class="section section7"></div> <div class="section section8"></div> <div class="section section9"></div> <div class="section section15"></div> </div> </div>
</body> </html>
|
17_京东布局案例03
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .container { width: 990px; height: auto; background-color: #f00; margin: 0 auto; }
.wrap { margin-right: -10px; }
.item { float: left;
margin-right: 10px; width: 240px; background-color: orange; }
.itema { height: 306px; }
.itemb { height: 148px; }
.item-last { margin-top: 10px; } </style> </head> <body> <div class="container"> <div class="wrap"> <div class="item itema"></div> <div class="item itema"></div> <div class="item itemb"></div> <div class="item itemb"></div> <div class="item itemb item-last"></div> <div class="item itemb item-last"></div> </div> </div>
<p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p>
</body> </html>
|
18_浮动考拉案例练习01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="`"> <title>Document</title>
<style> h2 { margin: 0; padding: 0; }
a { text-decoration: none; color: #666; }
.f-left { float: left; }
.f-right { float: right; }
.header { width: 1100px; margin: 0 auto; height: 49px; }
.header-left { font-size: 14px; }
.header-left h2, .header-left span, .header-left a { float: left; margin-right: 20px; }
.header-left h2 { font-size: 22px; }
.header-left .search { margin-top: 9px; }
.header-left .search a:hover { text-decoration: underline; }
.header-left .search .hot { color: #ff080f; }
.header-right { margin-top: 9px; font-size: 14px; }
.header-right a:hover { text-decoration: underline; } </style> </head> <body> <div class="header"> <div class="header-left f-left"> <h2>美妆专区</h2> <div class="search f-left"> <span>热搜词:</span> <a href="#">面膜</a> <a class="hot" href="#">口红</a> <a href="#">眼霜</a> <a class="hot" href="#">精华</a> <a href="#">卸妆</a> </div> </div> <div class="header-right f-right"> <a href="#">更多好货 ></a> </div> </div>
</body> </html>
|
19_浮动考拉案例练习2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> ul { list-style: none; padding: 0; margin: 0; }
.brand { width: 1100px; height: 180px; margin: 0 auto; }
.brand ul { margin-right: -10px; }
.brand ul li { float: left; width: 219px; height: 167px; margin-right: -1px;
border: 1px solid #eaeaea; }
</style> </head> <body> <div class="brand"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div>
</body> </html>
|
20_浮动考拉案例练习3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> ul { list-style: none; margin: 0; padding: 0; }
.today { width: 1100px; margin: 0 auto; }
.today ul { margin-right: -3px; }
.today ul li { float: left; width: 420px; height: 190px; background-color: #f00;
border: 1px solid #333; margin-right: -1px; margin-bottom: -1px; }
.today ul .last { float: right; width: 260px; height: 381px; background-color: #0f0; }
</style> </head> <body> <div class="today"> <ul> <li class="last"><a href="#"></a></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> </body> </html>
|
21_浮动考拉案例练习-04
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> ul { list-style: none; margin: 0; padding: 0; }
.wrap { width: 1100px; margin: 0 auto; }
.beauty .left { float: left; width: 329px; height: 541px; border: 1px solid #eaeaea; margin: 0 0 -1px -1px; }
.beauty .middle { float: left; width: 550px; height: 541px; }
.beauty .middle li { float: left;
width: 274px; height: 270px; border: 1px solid #eaeaea; margin: 0 0 -1px -1px; }
.beauty .right { float: left; width: 219px; height: 541px; border: 1px solid #eaeaea; margin: 0 0 -1px -1px; }
</style> </head> <body> <div class="wrap"> <div class="beauty"> <div class="left"></div> <div class="middle"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> <div class="right"></div> </div> </div>
</body> </html>
|
22_京东布局案例-清除浮动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .container { width: 990px; background-color: #f00; margin: 0 auto; }
.wrap { margin-right: -10px; }
.item { float: left;
margin-right: 10px; width: 240px; background-color: orange; }
.itema { height: 306px; }
.itemb { height: 148px; }
.item-last { margin-top: 10px; }
/* .container::after { content: ""; clear: both; display: block; }
.content::after { content: ""; clear: both; display: block; }
.brand::after { content: ""; clear: both; display: block; } */ .clear-fix::after { content: ""; clear: both; display: block;
height: 0; visibility: hidden; }
.clear-fix { *zoom: 1; } </style> </head> <body> <div class="container clear-fix"> <div class="wrap"> <div class="item itema"></div> <div class="item itema"></div> <div class="item itemb"></div> <div class="item itemb"></div> <div class="item itemb item-last"></div> <div class="item itemb item-last"></div> </div> </div>
<div class="brand clear-fix"></div>
<p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p> <p>其他内容</p>
</body> </html>
|
23_flex布局的使用01
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .box { width: 550px; height: 400px; background-color: orange; margin: 0 auto; /* 1.开启flex布局: flex: 块级元素 inline-flex: 行内元素 */ display: flex;
flex-flow: row wrap; justify-content: space-evenly;
align-content: space-around; }
.item { width: 100px; height: 100px; color: #fff; text-align: center; }
.item1 { background-color: #f00; }
.item2 { background-color: #0f0; }
.item3 { background-color: #00f; } </style> </head> <body> <div class="box"> <div class="item item1">item1</div> <div class="item item2">item2</div> <div class="item item3">item3</div> <div class="item item1">item4</div> <div class="item item2">item5</div> <div class="item item3">item6</div> <div class="item item1">item7</div> <div class="item item2">item8</div> <div class="item item3">item9</div> </div>
<strong>strong元素</strong>
</body> </html>
|
24_flex布局的使用02
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title>
<style> .box { width: 550px; height: 400px; background-color: orange; margin: 0 auto; display: flex;
}
/* 750px - 550px = 200px 200 / 3 = 66.66666px 250 - 66 = */
/* 200 / 5 = 40 */
.item { width: 100px; height: 100px; color: #fff; text-align: center;
flex: 1; }
.item1 { background-color: #f00;
}
.item2 { background-color: #0f0; }
.item3 { background-color: #00f; } </style> </head> <body> <div class="box"> <div class="item item1">item1</div> <div class="item item2">item2</div> <div class="item item3">item3</div> </div>
<strong>strong元素</strong>
</body> </html>
|