nth-child 的一些小尝试
2016-01-11 17:18
288 查看
nth-child 的一些小尝试
前言
对于 first-child 或者 last-child 等,还算比较常用.但是 nth-child 一般也就用隔行变色.一直不认为其有多强大的功能,甚至认为其比较鸡肋.但是今天深入研究了一下,发现这货不是一点半星的强大啊!!!!不废话,直接上代码
code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>nth-child test</title> </head> <body> <ul> <li>this is title 1</li> <li>this is title 2</li> <li>this is title 3</li> <li>this is title 4</li> <li>this is title 5</li> <li>this is title 6</li> <li>this is title 7</li> <li>this is title 8</li> <li>this is title 9</li> <li>this is title 10</li> <li>this is title 11</li> <li>this is title 12</li> <li>this is title 13</li> <li>this is title 14</li> <li>this is title 15</li> <li>this is title 16</li> <li>this is title 17</li> <li>this is title 18</li> <li>this is title 19</li> <li>this is title 20</li> </ul> </body> </html> <style> li:nth-child(1){background: #fda;} li:nth-child(3n){background: #daf;} li:nth-child(-n+4) {font-weight: bold;} li:nth-child(5n){border-bottom: 1px solid #ddd;padding-bottom: 20px;margin-bottom: 20px;} li:nth-child(n+5) {text-indent: 10px;} li:nth-child(3n+1) {color: #f00;} li:nth-child(3n-1) {color: #00f;} </style>
太TM灵活了,以后这种地方,根本就不需要加上 class啦!!!!
更多内容阅读
精通:nth-child关于nth-child的疑惑
w3school:CSS3 :nth-child() 选择器我就是看了这个才认为这玩意儿鸡肋的,W3S害死人啊!!!
相关文章推荐
- Ubuntu 14.04下NFS安装配置
- python解析xml文件注意
- PHP 连接SQL2008实践
- redis入门
- 我写的一个 Qt 显示图片的控件
- 类似时间轴的样式
- zabbix2.2.2-hostgroups.php代码分析(1)
- 数据结构复习
- sql 更新一列为行号
- HTML5新增属性
- iOS UIImage 图片局部拉伸的一些学习要点
- 老李分享:robotium3.6与4.0 later 的区别 2
- 39. Combination Sum && 40. Combination Sum II
- Unicode Tips
- liunx 批量删除进程 利用xargs
- iOS~block的使用
- 数据库设计三大范式
- Oracle 修改任意用户密码
- 老李分享:robotium3.6与4.0 later 的区别 1
- 关于如何控制一个页面的Ajax读数据只读一次的简单解决办法!