This article mainly introduces the CSS3 implementation of the smooth transition effect when the pseudo-class hover leaves. It has certain reference value. Those who are interested can learn about it.
Due to the animation effect added by the hover pseudo-class, it can only be used when It will be triggered when the mouse is placed on the element, and when the mouse leaves, the effect will be interrupted and it will appear very stiff.
Most people’s idea is to use the onmouseover and onmouseleave events of js to achieve animation effects. In fact, it doesn’t have to be so troublesome, CSS3 can help you solve these problems.
Because the p element can only be added to the p element when the :hover pseudo-class is triggered.
When the mouse leaves the p element, the :hover pseudo-class will no longer take effect, and the animation effect written in hover will be lost instantly.
At this time, we should write an identical transition effect on the original element to continue the interrupted animation effect.
At this time, no matter when the mouse leaves the element, it will return unchanged.
The above is the detailed content of Detailed explanation of examples of CSS3 implementing smooth transition when hover leaves. For more information, please follow other related articles on the PHP Chinese website!