简体   繁体   中英

Background image transition on hover

I have html page and I set background image in css rule:

body{ background-image:url("/someurl");}

And i have button, when i hover it I'm change background image. But i do it using JQuery like this

body.css('background-image', 'url(' + initialimageSrc + ')');

I 'd like to have a transition on backgound-image change, but when I use

transition:background-image 2s linear;

It looks very bad. Can any one help?

well, actually, this way of transitioning a background-image only supports fade-in, fade-out, and doesn't really offer any customisability. my advice is to create a second object, which will fade in and out alternatively.

try to follow the conventions in http://css3.bradshawenterprises.com/cfimg/ - it helped me a lot with that subject.

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