html - When hover on Image opacity doesn't apply -


i have problem when hover on image must use opacity + overlay text, , when text overlays image opacity don't work correctly, did wrong in code?

here css code

.grid {   display: inline-block;   position: relative;   cursor: pointer;   border: 2px solid  white;   overflow: hidden; }    .grid:hover .text-overlay {     display: block; }    .grid img {     width: 308px; }    .grid .img-grid {     display: block;     position: relative; }     .grid .img-grid:hover {       opacity: .5; }    .grid .text-overlay {     text-align: center;     position: absolute;     width: 100%;     top: 15px;     z-index: 1;     display: none;     font-size: 18px; } 

jsfiddle

instead of

.grid .img-grid:hover { opacity: .5; } 

you should use

.grid:hover .img-grid { opacity: .5; } 

because when caption appears lose hover state on img element


see demo


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -