ButtonsTutorials

how to create a button animation pure CSS

how to create a button animation pure CSS

how to create a button animation pure CSS

Before We Start

Every developers need, clean and modern elements to develop their websites, It contain pictures and a user interface element within a website. The most important one and the first section that the user sees when he/she enters a website. how to create a button animation pure CSS

So if you are a person who wishes to develop a website, you have to know how to create that properly.

how to create a button animation pure CSS

We are here to solve your problem. In this article we discuss how to create this elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.

Step 1 – Add HTML

It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.

<body>
  <div class="container">
    <div class="center">
      <button class="button"><span class="dot"></span><svg class="check" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-check fa-w-16 fa-3x">
          <path fill="#2079ff" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z" class=""></path>
        </svg><svg class="svg" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="paper-plane" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-paper-plane fa-w-16 fa-3x">
          <path fill="#2079ff" d="M476 3.2L12.5 270.6c-18.1 10.4-15.8 35.6 2.2 43.2L121 358.4l287.3-253.2c5.5-4.9 13.3 2.6 8.6 8.3L176 407v80.5c0 23.6 28.5 32.9 42.5 15.8L282 426l124.6 52.2c14.2 6 30.4-2.9 33-18.2l72-432C515 7.8 493.3-6.8 476 3.2z" class=""></path>
        </svg><span class="text">Send email</span>
        <div class="text2">Sent!</div>
      </button>

    </div>
  </div>
</body>

<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400&family=Roboto&display=swap" rel="stylesheet">

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag.

<style>
body {
  background-color: #00dbde;
  background-image: linear-gradient(90deg, #00dbde 0%, #fc00ff 100%);
}

.container {
  height: 200px;
  position: relative;
}

.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

.button {
  margin: auto;
  margin-top: 100px;
  width: 250px;
  height: 50px;
  background: #ddd;
  text-align: center;
  font-family: "Open Sans", sans-serif;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  border-radius: 10px;
  color: #333;
  font-weight: 400;
  border: none;
  transition-duration: 0.5s;
  padding-left: 58px;
}

.button:hover {
  color: #2079ff;
  background: #e8e8e8;
}

.button:focus {
  outline: none;
  background: #b4d2ff;
  color: #2079ff;
  transition-duration: 0.5s;
}

.svg {
  position: absolute;
  height: 34px;
  margin-top: -22px;
  margin-left: -54px;
  transition-duration: 1s;
}

.check {
  position: absolute;
  opacity: 0%;
  height: 32px;
  margin-top: 0px;
  margin-left: -50px;
  transition-duration: 0.5s;
}

.text2 {
  position: absolute;
  margin-top: -24px;
  margin-left: 70px;
  color: #2079ff;
  opacity: 0%;
}

.button:focus .svg {
  opacity: 0%;
  height: 5px;
  margin-top: -36px;
  margin-left: -20px;
  transition-duration: 0.5s;
}

.button:focus .check {
  opacity: 100%;
  margin-top: -5px;
  transition-duration: 0.5s;
  transition-delay: 0.6s;
}

.button:focus .dot {
  opacity: 0%;
  margin-top: 10px;
  margin-left: -40px;
  transform: scale(0.1);
  transition-duration: 0.4s;
}

.button:focus .text2 {
  opacity: 100%;
  transition-duration: 0.4s;
  transition-delay: 0.9s;
}

.button:focus .text {
  opacity: 0%;
  transition-duration: 0.5s;
}

.dot {
  position: absolute;
  background-color: #ccc;
  text-align: center;
  height: 7px;
  width: 28px;
  border-radius: 50%;
  margin-top: 20px;
  margin-left: -50px;
  transition-duration: 1s;
}

.button:hover .svg {
  margin-top: -27px;
  transition-duration: 0.5s;
}

.button:hover .dot {
  transform: scale(0.8);
  transition-duration: 0.5s;
}

</style>

At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want.Enjoy it.

Before

how to create a button animation pure CSS

After

how to create a button animation pure CSS

Video Tutorial

Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.


Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button