开发者

Have you ever seen such kind of css selectors?

开发者 https://www.devze.com 2023-01-18 08:25 出处:网络
table t开发者_JAVA技巧d+td+td+td+td+td{ display:table-cell; } What does + mean?It is the adjacent sibling selector.
table t开发者_JAVA技巧d+td+td+td+td+td{
    display:table-cell;
}

What does + mean?


It is the adjacent sibling selector.

So if you have sth. like:

<table> 
    <tr>
        <td></td> <!-- starting from here A-->
        <td></td> <!-- starting from here B-->
        <td></td>
        <td></td>
        <td></td>
        <td></td> <!-- selects this one A -->
        <td></td> <!-- selects this one B -->
    </tr>
</table>

So the last two cells in this example will be selected. See here: http://jsfiddle.net/ERkEk/

The whole CSS selector seems not very useful to me (personal opinion) like hardcoding to me. It might be necessary in some cases, but it is harder to maintain than using classes. You very much rely on the markup in this case.

Update: It is supported in all browsers but IE 5.5 and IE 6 and is not 100% supported in IE <= 8.


Adjacent sibling selector.

Thus, the following rule states that when a P element immediately follows a MATH element, it should not be indented:

math + p { text-indent: 0 } 

http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors

0

精彩评论

暂无评论...
验证码 换一张
取 消