How we can create an animated click effect using only HTML & CSS? Solution: See this Pure CSS Click Effect With Animation, HTML CSS Button Press Effect.
Previously I have shared button hover effects, but this is a click effect that you can use on any element not only button. Basically, when we click on an element or button on modern websites and apps, there is an animation effect on click. We can create a kind of button press effect using pure HTML and CSS.
Today you will learn to create HTML CSS Button Press Effect. This is related to a little bit ripple effect, but its animation spread on outside the button. Basically, there are 4 icons and all the icons have the same click effect. When you will click on any icon then there will an effect reveal on the backside of the icon like a multi-circle spreading.
So, Today I am sharing Pure CSS Click Effect With Animation. There I have used pure CSS to create the effect because, the animation is very basic which we can create using basic CSS command. I did not use JS or any other library to creating this, and I have shared many buttons related program in the past you can check out.
If you are thinking now how this click animation actually is, then see the preview given below.
Preview Of HTML CSS Button Press Effect
See this video preview to getting an idea of how this button press effect looks like.
Now you can see this visually, also you can see it live by pressing the button above. If you like this, then get the source code of its.
You May Also Like:
- Expanding Button On Hover
- Parallax Tilt Effect Card
- Material Login & Signup Form
- HTML CSS Creative Slider
Pure CSS Click Effect With Animation Source Code
Before sharing source code, let’s talk about it. First I have created a main div named container and placed 4 divs inside it. In all four divs I have placed a same class name “button” and inside each button div, I have placed a span tag. The span tag is for placing the icon, all these icons are based on ionicons (get).
Now using CSS I have placed all the elements in the right place, as you can see in the preview. I have placed items in the center using position & text-align command. After that, I gave the height and width to the icons and created a blank content with white background for creating the background circle. And finally for creating the animation I have used CSS @keyframe command and scale up the circle in 3 parts.
Left all other things you will understand after getting the codes, I can’t explain all in writing. For creating this effect program, you have to create only 2 files. First file for HTML and second 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 below.
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 |
<!DOCTYPE html> <!-- Code By Webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>Pure CSS Click Effect | Webdevtrick.com</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css'> <link rel="stylesheet" href="./style.css"> </head> <body> <div class="container"> <div class="wrap"> <div class="button" tabindex="1"> <span class="ion-ionic"></span> </div> <div class="button" tabindex="2"> <span class="ion-plus-circled"></span> </div> <div class="button" tabindex="3"> <span class="ion-heart"></span> </div> <div class="button" tabindex="3"> <span class="ion-power"></span> </div> <hr /> <h3>CSS Click Effect</h3> </div> </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 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 85 86 87 88 89 |
/* Code By Webdevtrick ( https://webdevtrick.com ) */ @charset "UTF-8"; body { background-color: #fd3b3b; color: #fff; padding-top: 25%; text-align: center; } .wrap { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } h3 { font-family: 'Roboto Condensed'; color: #fff; font-weight: 300; } .button { position: relative; display: inline-block; cursor: pointer; margin: 0 auto; width: 70px; height: 70px; font-size: 52px; transition: all 0.4s ease-in; } .button span[class^='ion'] { position: relative; } .button:before { content: ''; background-color: #fff; border-radius: 50%; display: block; position: absolute; top: 0; right: 0; bottom: 0; left: 0; -webkit-transform: scale(0.001, 0.001); transform: scale(0.001, 0.001); } .button:focus { outline: 0; color: #fff; } .button:focus:before { -webkit-animation: Click_Effect 0.8s ease-out; animation: Click_Effect 0.8s ease-out; } @-webkit-keyframes Click_Effect { 50% { -webkit-transform: scale(1.5, 1.5); transform: scale(1.5, 1.5); opacity: 0; } 99% { -webkit-transform: scale(0.001, 0.001); transform: scale(0.001, 0.001); opacity: 0; } 100% { -webkit-transform: scale(0.001, 0.001); transform: scale(0.001, 0.001); opacity: 1; } } @keyframes Click_Effect { 50% { -webkit-transform: scale(1.5, 1.5); transform: scale(1.5, 1.5); opacity: 0; } 99% { -webkit-transform: scale(0.001, 0.001); transform: scale(0.001, 0.001); opacity: 0; } 100% { -webkit-transform: scale(0.001, 0.001); transform: scale(0.001, 0.001); opacity: 1; } } |
That’s It. Now you have successfully created Pure CSS Click Effect With Animation, HTML CSS Button Press Effect. If you have any doubt or question comment down below.
Thanks For Visiting, Keep Visiting.