How we can create an animated ghost button using HTML and CSS? Solution: Check out this CSS Gradient Ghost Button With Animation, Moving Gradient Fill.
Previously I have shared ghost buttons with icon, but this ghost button is with moving gradient. Maybe you about that button basically, this is a button with flat design and transparent background. But the border and text have a moving gradient design in this button and that makes it a unique and beautiful design.
Today you will learn to create moving gradient filling ghost button. Basically, there is a button’s border and text inside the button with a moving gradient fill. The gradient continuously moves over the button, there is 3 color gradient that’s why we can see the movement. Also, there is a border join animation on starting or page load.
So, Today I am sharing CSS Gradient Ghost Button With Animation. This is a pure CSS UI design concept, you can use this any place that will be fit on everywhere. And this is a very easy design, even a beginner can understand the codes easily. After understanding the code you can implement this type of moving gradient on other elements.
If you are thinking now how this Moving gradient fill button actually is, then see the preview given below.
Preview Of Moving Gradient Fill Button
See this video preview to getting an idea of how this button 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 Flat Navigation Bar
- CVG Button Hover Animation
- Multiple Text Effect Styles
- Input Label Animation
CSS Gradient Ghost Button With Animation Source Code
Before sharing source code, let’s talk about it. First, I have created an HTML hyperlink using <a> tag. And I have placed a span with text inside the hyperlink tag. I have put the width and height value of the hyperlink tag and creates a border that makes it a kind of button. After that, I have placed the span text middle of the button using proper line-height (info).
Now using CSS first I have placed all elements like the button placed a middle and also the text. Now I have put a gradient in the text and also in the border with 120 degrees rotation. Now I have created a clip-path to fill the border and also created a @keyframe animation. I have used polygon clip-path and put the values.
Also, I have created another @keyframe animation for changing the background’s position of the gradient. That is the whole concept, left all other things you will understand easily after getting the codes. For creating this button 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 |
<!DOCTYPE html> <!--Code By Webdevtrick ( https://webdevtrick.com )--> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Gradient Ghost Button | Webdevtrick.com</title> <link href="https://fonts.googleapis.com/css?family=Squada+One&display=swap" rel="stylesheet"> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <a href="https://webdevtrick.com" target="_blank"><span>button</span></a> </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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
/** Code By Webdevtrick ( https://webdevtrick.com ) **/ body { background: #212121 url(https://webdevtrick.com/wp-content/uploads/sunset-background.jpg) 0 0 no-repeat; background-size: cover; } body:after { content: ''; background: rgb(33,33,33, 0.85); } a { display: block; width: 220px; height: 70px; z-index: 1; } a:after { content: ''; background: linear-gradient(120deg, #8A2387, #E94057, #F27121); background-size: 400% 400%; -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 4px, 216px 4px, 216px 66px, 4px 66px, 4px 100%, 100% 100%, 100% 0%, 0% 0%); -moz-animation: gradient 3s ease-in-out infinite, border 1s forwards ease-in-out reverse; -webkit-animation: gradient 3s ease-in-out infinite, border 1s forwards ease-in-out reverse; animation: gradient 3s ease-in-out infinite, border 1s forwards ease-in-out reverse; } a > span { display: block; background: linear-gradient(120deg, #8A2387, #E94057, #F27121); background-size: 400% 400%; -webkit-background-clip: text; -webkit-text-fill-color: transparent; -moz-animation: gradient 3s ease-in-out infinite; -webkit-animation: gradient 3s ease-in-out infinite; animation: gradient 3s ease-in-out infinite; } body:after, a, a:after { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; } a { font-family: 'Squada One', cursive; text-transform: uppercase; text-decoration: none; text-align: center; letter-spacing: 3px; line-height: 70px; font-size: 30px; } @keyframes gradient { 0% { background-position: 14% 0%; } 50% { background-position: 87% 100%; } 100% { background-position: 14% 0%; } } @keyframes border { 0% { -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 4px, 216px 4px, 216px 66px, 4px 66px, 4px 100%, 100% 100%, 100% 0%, 0% 0%); } 25% { -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 4px, 216px 4px, 216px 66px, 216px 66px, 216px 100%, 100% 100%, 100% 0%, 0% 0%); } 50% { -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 4px, 216px 4px, 216px 4px, 216px 4px, 216px 4px, 216px 4px, 100% 0%, 0% 0%); } 75% { -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 4px, 4px 4px, 4px 4px, 4px 4px, 4px 4px, 4px 4px, 4px 0%, 0% 0%); } 100% { -webkit-clip-path: polygon(0% 100%, 4px 100%, 4px 100%, 4px 100%, 4px 100%, 4px 100%, 4px 100%, 4px 100%, 4px 100%, 0% 100%); } } @media (max-width:765px) { body { background: #344557; } } |
That’s It. Now you have successfully created CSS Gradient Ghost Button With Animation, Moving Gradient Fill. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.
Bhai apne post k uper social share button kaise lagaye…plz blogger me kaise add kre reply me….
Hey Shaan,
I am beginner in this field and i also try few little drops but i stuck when i use scale transformation in any image, it reflects over the area. Can you please make a video to relate subject Overflow and Scale method.