I have a jquery carousel that is applying a class of 'active' to an image that is in a div. In this same div I also have a span with a class of 'fade' which is applying a css style of opacity: 0; I am wondering if there is a way either with CSS or javascript to change the CSS style of span class to opacity: 1; when the image (which is on the same level of the span tag) has the 'active' class applied to it.
<div>
<img src="image1" class="active">
<span class="fade">
<p>Text</p>
</span>
</div>
I have a jquery carousel that is applying a class of 'active' to an image that is in a div. In this same div I also have a span with a class of 'fade' which is applying a css style of opacity: 0; I am wondering if there is a way either with CSS or javascript to change the CSS style of span class to opacity: 1; when the image (which is on the same level of the span tag) has the 'active' class applied to it.
<div>
<img src="image1" class="active">
<span class="fade">
<p>Text</p>
</span>
</div>
Share
Improve this question
asked Dec 30, 2012 at 8:21
Tristan MartinTristan Martin
351 silver badge3 bronze badges
1 Answer
Reset to default 6In CSS use adjacent sibling selector:
img.active + span.fade {
/* styles here */
}
DEMO: http://jsfiddle/QBfPg/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745451871a4628308.html
评论列表(0条)