简体   繁体   中英

Fade in/out background image on hover

Instead of transitions left to right, right to left. How can I make it to fade in fade out, no movements, just opacity fade out, fade in.

http://designshack.net/articles/css/swap-your-pages-background-image-on-navigation-hover/

You can do this with the CSS3 properties opacity and transition

.yourClass
{
    opacity: 1;
    transition: all 3s ease;
} 

.yourClass:hover 
{
    opacity: 0;
}

An example here :

http://jsfiddle.net/ghBAT/

If you are ok with jquery - have a look at .fadeIn()

<div id="clickme">
  Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123">

// With the element initially hidden, we can show it slowly:
$( "#clickme" ).click(function() {
  $( "#book" ).fadeIn( "slow", function() {
    // Animation complete
  });
});

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