Back
Master the art of creating a mesmerizing animated loader with smooth transitions and dynamic visual effects that captivate users.
<div class="loader-container"> <div class="loader"></div> </div>
loader
and its container.
Let us start with the styling for the loader-container
. This class will center the loader in the middle of the viewport using Flexbox.
.loader-container { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f8f9fa; }Next, let's style the
loader
itself. It will be circular in shape due to the large border-radius
. We'll apply gradient border colors to enhance its appearance, creating a sleek spinning animation.
The use of the transform
property in combination with @keyframes
defines its rotation.
.loader { border: 16px solid #f3f3f3; border-top: 16px solid #3498db; border-radius: 50%; width: 120px; height: 120px; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }We have defined the spinning effect by rotating the loader 360 degrees continuously, making it appear as a real loader during page loads or processes.
#3498db
with any hex color will change the loader's animation color.animation-duration
to create slower or faster spinning effects.width
and height
, you can own a loader that fits perfectly on your page.<div class="loader-container"> <div class="loader"></div> </div> <style> .loader-container { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f8f9fa; } .loader { border: 16px solid #f3f3f3; border-top: 16px solid #3498db; border-radius: 50%; width: 120px; height: 120px; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style>Thank you for reading this article.
Comments