Home >Web Front-end >CSS Tutorial >How Can I Achieve a Smooth Background Image Transition with CSS3?
CSS3 Background Image Transition
When implementing a "fade-in fade-out" effect using CSS transitions, it may not work with background images. To overcome this, the background-image property needs to be targeted specifically.
In the CSS provided, the code attempting to transition the background image is:
-webkit-transition: background 1s; -moz-transition: background 1s; -o-transition: background 1s; transition: background 1s;
To transition the background image, use the following code on the element with the background image (usually an tag):
-webkit-transition: background-image 0.2s ease-in-out; transition: background-image 0.2s ease-in-out;
This syntax is natively supported by Chrome, Opera, and Safari. Firefox and Internet Explorer do not support this feature currently.
The above is the detailed content of How Can I Achieve a Smooth Background Image Transition with CSS3?. For more information, please follow other related articles on the PHP Chinese website!