Table
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
| <!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> table{ border-collapse: collapse; } td, th { text-align: center; border: 1px solid #333; padding: 8px 16px; }
</style> </head> <body> <table> <caption>xixihaa</caption> <thead> <tr> <th>排名</th> <th>名字</th> <th>代码</th> <th>价格</th> <th>涨跌</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>xixihaha</td> <td>oooo</td> <td>24</td> <td>10%</td> </tr> <tr> <td>1</td> <td>xixihaha</td> <td>oooo</td> <td>24</td> <td>10%</td> </tr> <tr> <td>1</td> <td>xixihaha</td> <td>oooo</td> <td>24</td> <td>10%</td> </tr> </tbody> </table> </body> </html>
|
- type:text, password,
- 经典按钮:button, submit,reset
点击input框前的文字即可激活跳转到框中
select和option
1 2 3
| <select name="alugg"> <option value="apple">爱吃苹果</option> </select>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <form action="/abc" method="post"> <div> <label for="username" > User:<input id="username" type="text" name="username"> </label> <label for="password"> password:<input id="password" type="password" name="password"> </label> </div> <div> <label for="male"> <input id="male" type="radio" name="sex" value="male">male </label> <label for="female"> <input id="female" type="radio" name="sex" value="female">female </label> </div> <button type="submit">Submit</button> </form>
|
结构伪类
nth-child
nth-child(1):是父元素的第1个子元素
nth-child(2n):是父元素的第2,4,6个子元素
nth-chid(-n+5):前5个
nth-last-child:从后往前数
nth-of-type
同样也有nth-last-of-type
第几个符合类型的元素.
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
| <!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> .box > div:nth-child(4){ color: red; } .box > div:nth-of-type(4){ color: blue; } </style> </head> <body> <div class="box"> <p>xixixha</p> <div>list1</div> <h1>ooo</h1> <div>list2</div> <div>list3</div> <h1></h1> <div>list4</div> <div>list5</div> <div>list</div> <div>list</div> </div> </body> </html>
|
其他伪类
first-child
first-of-type
only-child
only-of-type
empty
否定结构伪类
:not(xxx):不是xx的才被选中
CSS sprite
一种图像合成技术,把各种小图片合并到一张图片上,然后利用CSS的背景定位来显示对应的图片部分.
好处:
- 减少网页http请求数量,加快网页相应速度,减少服务器压力
- 减少图片总大小
- 解决了图片命名的困扰
获得了精灵图后,去sprite cow上定位具体的各个图片
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <!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> .topbar{ background-image: url(../../image_files/cc1d8d291ea917c0.png); background-repeat: no-repeat; display: inline-block; } i.hot-icon{ background-position:-205px 0 ; width: 103px; height: 32px; } </style> </head> <body> <i class="topbar hot-icon"></i> </body> </html>
|