开发者

CSS Behaviour for IE: first-of-type

I wanted to use a CSS behaviour to target the first p element in a div, which is not the first element in the div.

I saw a simila开发者_JS百科r question on here which answered with using cascading selectors to the p in the div, like:

div h1 p

As I may not know what the first element may be (maybe h1 or h2 etc, I was wondering whether it was possible to mimic the :first-of-type using IEs behaviours in CSS.

Thanks in advance for any help.


This works fine

div p:first-of-type {
    background:red;
}

for this

<div>
    <h1>Test</h1>
        <p>Something</p>
        <p>Something else</p>
</div>

Example: http://jsfiddle.net/jasongennaro/zJaAa/1/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜