admin管理员组文章数量:1425758
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/
本文标签: javascriptApplying a CSS style to a class based on another class on the same levelStack Overflow
版权声明:本文标题:javascript - Applying a CSS style to a class based on another class on the same level - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745451870a2658924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论