[ACCEPTED]-I would like to apply css to the first image-css
Accepted answer
:first-child
selects for only the first child of the 4 parent element. In OPs example :first-child
would be 3 the h1
so img:first-child
would not actually select anything.
Use 2 nth-of-type(1)
instead.
http://reference.sitepoint.com/css/pseudoclass-nthoftype
<!-- in the head -->
<style>
.post_locked2 img:nth-of-type(1){
border:5px solid red;
}
</style>
<!-- in the body -->
<div class="post_locked2">
<img class="aligncenter" src="http://www.what...
<img title="RockDizFile" src="http://......
<img title="Bullet" src="http://wwww.......
</div>
And here's another example of 1 it in use: http://jsfiddle.net/FsEhD/
Have you tried this?
post_locked2>.aligncenter:first-child {some:styles;}
or
post_locked2>img:first-child {some:styles;}
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.