html - How to show div on hover of a image? -
i have code this....
<div class="col-lg-8 col-xs-12 col-sm-7 col-md-8 " style="vertical-align:top;"> <img src="images/url.jpg" class="banner_img" /> <div class="banner_caption"> <h3>banner caption here</h3> </div> </div>
and css this...
.banner_caption{ background-color:rgba(0,0,0,0.3); width:100%; padding:5px; position:absolute; bottom:-60px; display:none; left:0; color:#fff; transition-delay:1s; transition:all 1s; } .banner_img:hover .banner_caption{ bottom:0px; display:block; }
banner_caption div should appear when hover on image... unable that....anyone having ideas solve this?
just give this:
.banner_img:hover + .banner_caption
the plus (+
) called sibling selector.
.banner_img:hover + .banner_caption{ bottom: 0; display: block; }
the reason behind why yours doesn't work is:
.banner_img:hover .banner_caption
:.banner_caption
inside.banner_img
..banner_img:hover + .banner_caption
:.banner_caption
adjacent.banner_img
.
so need use second 1 above.
Comments
Post a Comment