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/
加载中,请稍侯......
精彩评论