css3 - Display text in a div only when a CSS transition kicks in? -


i have following:

http://jsfiddle.net/zf5am/579/

i'm trying display text when hover effect (transparency) kicks in. text should full-opacity, readable, on hover, on top of opaque image. can done using css?

<div class="image"> <img class="fade" src="http://www.newyorker.com/online/blogs/photobooth/nasaearth-01.jpg" alt="" /> <div class="text">test</div> </div>  .image img { width:200px; height:200px; } .fade {     opacity: 1; transition: opacity .25s ease-in-out; -moz-transition: opacity .25s ease-in-out; -webkit-transition: opacity .25s ease-in-out; } .fade:hover {     opacity: 0.4; } .image{     background-color: black;     width: 300px; } .text{     color: red;     position: absolute;     top: 10px;     left: 100px;     visibility: hidden;     width: 100%;     height: 100%; } .text:hover{     visibility: visible; } } 

instead of triggering on hover of child element, use nested selectors trigger on hover of containing element:

div:hover .fade {     opacity: 0.4; } div:hover .text{     visibility: visible; } 

this way can work since otherwise elements obscuring eachother, not both getting :hover behaviour themselves. parent though, allowing select children.

working sample.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -