Home >Web Front-end >CSS Tutorial >How to Keep an Absolutely Positioned Element Centered During CSS3 Scale Animations?
How to Maintain Center Origin During Scale Animation
When using CSS3 animations to scale an element positioned absolutely in the center of another element, the resulting animation may appear off-center. This discrepancy arises because the animation overrides the initial translation that centers the element.
To resolve this issue and ensure that the origin remains centered during the scale animation, it's crucial to:
Updated Example:
@keyframes ripple_large { 0% { transform: translate(-50%, -50%) scale(1); } 75% { transform: translate(-50%, -50%) scale(3); opacity: 0.4; } 100% { transform: translate(-50%, -50%) scale(4); opacity: 0; } } .center-point { transform: translate(-50%, -50%) scale(0); }
With these modifications, the scaling animation will correctly maintain the element's center position within the parent container.
The above is the detailed content of How to Keep an Absolutely Positioned Element Centered During CSS3 Scale Animations?. For more information, please follow other related articles on the PHP Chinese website!