简体   繁体   中英

Removing image overlay on hover

I am trying to remove an image overlay on hover. I have the following code that adds an overlay on hover but I want it to have an opacity when not hovered upon and remove that opacity when hovered.

jQuery:

revapi1.on('revolution.slide.onloaded', function() {

revapi1.find('li').each(function() {

var slide = jQuery(this);
if(slide.find('.slidelink').length) {

slide.find('.slotholder').addClass('custom-hover');

}

});
});

CSS:

.rev_slider .custom-hover {

-webkit-transition: opacity 0.5s ease-out;
-moz-transition: opacity 0.5s ease-out;
-o-transition: opacity 0.5s ease-out;
transition: opacity 0.5s ease-out;

} 

.rev_slider:hover .custom-hover {

opacity: 0.5;

}

I have tried the following. It works but I can't get it to work with the Jquery code above. Fiddle

HTML:

<div class="wrap">
<figure class="tint">
  <img src="http://cdn.impressivewebs.com/2011-11/greece001.jpg" alt=""   width="400" height="260" />
 </figure>
 </div>    

If you want to perform a CSS transition on opacity, you'll need to make sure that there is a default opacity property as well. So something like this:

.rev_slider .custom-hover {
    opacity: 0;
    -webkit-transition: opacity 0.5s ease-out;
    -moz-transition: opacity 0.5s ease-out;
    -o-transition: opacity 0.5s ease-out;
    transition: opacity 0.5s ease-out;
} 

.rev_slider:hover .custom-hover {
    opacity: 0.5;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM