How we can create movie gradient for the background using pure CSS? Solution: CSS Gradient Background Animation. In other words, Pure CSS moving gradient.
Previously I have shared a random gradient generator, but this is a simple moving gradient for background or on any element. Basically, a gradient is a mix of more than one color, that we can easily create using CSS for websites. I have shared some posts on gradient topic first, check out those.
Today you will learn to create a moving gradient background for your website. This is a basic and easy concept, one of our visitors asks me for creating this that’s why I am sharing this. After seeing this post, you will able to understand how CSS gradients work and how to create. Codes of this design are very easy, even a beginner understand quickly.
So, Today I am sharing CSS Gradient Background Animation. This is a normal linear gradient on the body with moving animation, that’s why I am calling it animated background gradient. There I have used some simple CSS properties like linear-gradient, background-size, animation, etc.
If you are thinking now how this moving background actually is, then see the preview given below.
Preview Of Moving Gradient
See this video preview to getting an idea of how this design looks like.
Now you can see this visually, you also can see it live by pressing the button given above. If you like this, then get the source code of its.
You May Also Like:
- CSS Border Transitions
- Clip Path Animation Cards
- Pure HTML CSS Dropdown Menu
- Grid Menu Layout With Flex
CSS Gradient Background Animation Source Code
Before sharing source code, let’s talk about it. I have created just one div for text otherwise, the gradient is on the body element. I have used a google font (get) for styling the headings on the design. In HTML file I have done these works only like put first heading, second heading, and link the font.
Now in the CSS file, I have placed gradient on the body tag. I have placed a linear gradient with four colors and -45 degrees angle, now the whole command line looks like this: background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab ); . After that, I have created an animation using CSS @keyframe and put 3 stage animation at 0%, 50%, and 100%.
Left other basic things you will understand easily after getting the codes, I can’t explain all in writing. For creating this you have to create only 2 files, one for HTML and one for CSS. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given here below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<!DOCTYPE html> <!--Code By Webdevtrick ( https://webdevtrick.com )--> <html lang="en" > <head> <meta charset="UTF-8"> <title>CSS Gradient Background | Webdevtrick.com</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Exo&display=swap'> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>CSS Animated Gradient Background</h1> <h2>Get More @ <a href="https://webdevtrick.com/">Webdevtrick</a></h2> </div> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes given here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/** Code By Webdevtrick ( https://webdevtrick.com ) **/ body { margin: 0; width: 100%; height: 100vh; font-family: "Exo", sans-serif; color: #fff; background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab ); background-size: 400% 400%; -webkit-animation: gradientBG 10s ease infinite; animation: gradientBG 10s ease infinite; } .container { width: 100%; position: absolute; top: 35%; text-align: center; } h1 { font-weight: 900; } a { text-decoration: none; color: #212121; } @-webkit-keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } @keyframes gradientBG { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } } |
That’s It. Now you have successfully created CSS Gradient Background Animation, Pure CSS Moving Gradient. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.
Is there a way for this to work using Adobe Muse?…I haven’t been able to get it to work.