THAPA TECHNICAL

HOUSE OF WEB DEVELOPERS AND TECHNOLOGY.

Creating Beautiful Gradient Animations with Pure CSS Only 🔥

Complete Source Code

 


The first three lines define the background gradient using a combination of fallback, vendor-specific, and standard CSS rules. The gradient includes four colors that blend together at an angle of -45 degrees: #5FC3E4 (a bright blue), #3ca55c (a darker green), #E55D87 (a bright pink), and #e5e5be (a pale yellow). The fallback and vendor-specific rules are included to support older browsers that may not support the standard gradient syntax.

The background-size property is set to 400% 400%, which means that the gradient will be four times larger than the element itself. This is because the background-position property will be changed during the animation to create the shifting effect, and a larger background size ensures that the gradient can cover the entire element during the animation.

The height property is set to 100vh, which means that the section will cover the full viewport height. The position property is set to relative, which allows the section to be positioned relative to its normal position in the document flow. The width property is set to 100% to ensure that the section covers the full width of its containing element.

The display property is set to grid, which allows the contents of the section to be centered horizontally and vertically using the place-items property. The text-align property is set to center to center any text within the section.

Finally, the animation property is set to gradient 10s linear infinite, which means that the gradient animation defined in the @keyframes rule will be applied to the background of the section. The animation will last for 10 seconds, use a linear timing function, and loop infinitely.

Also, the Keyframes part


The @keyframes rule defines the gradient animation that will be applied to the background of the section. The animation consists of three keyframes: 0%, 50%, and 100%.
At 0%, the background-position is set to 0% 50%, which means that the gradient will start at the left edge of the section and be vertically centered.
At 50%, the background-position is set to 100% 50%, which means that the gradient will have shifted to the right edge of the section and be vertically centered.
At 100%, the background-position is set back to `0%