选择器
- 属性选择器,使用标签+属性的形式选择.
E[attr^="b"] // 表示选择E标签中属性attr以b开头的元素
E[attr$="e"] //表示选择E标签中属性attr以e结尾的元素
E[attr*="s"]//表示E标签中属性attr中包含s字符的元素
- 选择子类元素
- first-child, 选择子类第一个元素
- last-child,选择子类最后一个元素
- nth-child(n),选择子类第n个元素
ul li:first-child{background-color:red;} ul li:nth-child(2){background-color:orange;} ul li:nth-child(3){background-color:yellow;} ul li:nth-child(4){background-color:green;} ul li:last-child{background-color:blue;}