写作背景
今天有个列表中第一行边框有特殊样式,第二个要求没有,其他的要求有边框
经常用:first-child 但是第二个确不是second-child
而是用css3的nth-child(n)但是有个兼容问题就查了一下资料,如下
说明
demo
/* standard nth */
ul.menu li:nth-child(3)
{
/* styles for the 3rd LI */
}
/* IE nth */
ul.menu>li + li + li
{
/* styles for the 3rd LI */
}
/* alternate, more specific IE nth */
ul.menu>li:first-child + li + li
{
/* styles for the 3rd LI */
}
自己用到的
.media:nth-child(2){
border: none;}
/*兼容IE8*/
.media:first-child +div{
border: none;
}
参考地址
http://blog.abouthalf.com/development/poor-mans-nth-child-selector-for-ie-7-and-8/