兄弟选择器 E + F

兄弟选择器在IE7下支持会有bug,特记于此html

   若是兄弟选择器有Html注释,兄弟选择器在IE7下会失效  代码以下web

E + F
IE7下 .test2,.test3,.test5,.test6会是红色,其他是黑色

ieie7

后代选择器 E > F  ,在IE7(Q)版本中,若是父元素与子元素有html注释,也会失效(未测试)测试

通用兄弟选择器没有这一个bugthis

 

ie

属性选择器会 ^  |  这两种 有一点要注意,若是一个元素有多个类名,要找的类名必须是第一位,不然,会忽视它,尽管符合条件 spa

ie

 

关于nth-child与nth-of-type选择器的差异code

  1.二者以前均可以不写元素选择器,若是不写没有任何差异htm

   2.若是写元素选择器,nth-child()中的数值表明的是在父元素中的索引位置,而nth-of-type中的数值指的是元素在父元素中相同元素间的位置 blog

 1  < div  class ="demo clearfix" >
 2  <!--  some message  -->
 3 < span >span1 </ span >
 4  < href ="" >a1 </ a >
 5  < href ="" >a2 </ a >
 6  < href ="" >a3 </ a >
 7  < href ="" >a4 </ a >
 8  < span >span2 </ span >
 9  < href ="" >a5 </ a >
10  < href ="" >a6 </ a >
11  < href ="" >a7 </ a >
12  < href ="" >a8 </ a >
13  < span >span3 </ span >
14  < href ="" >a9 </ a >
15  < href ="" >a10 </ a >

16 </div> 索引

1          .demo a{ color: #000; text-decoration:  none; font-size: 30px;}
2          .demo :nth-child(n+2){ color: red; font-size:  16px;}
3          .demo a:nth-child(2){ color: blue; background: yellow;}
4          .demo a:nth-of-type(3){ color: green; background: red;}
5          .demo span:nth-child(2){ color: black; font-size: 100px;}
6          .demo span:nth-of-type(2){ color: yellow; background: gray;}
7          .demo :nth-of-type(n+7){ color: #139ac7; background: #333;}

 

运行结果以下:get

 

相关文章
相关标签/搜索