Ripple Effect Button On Click Using HTML, CSS & Javascript

Hello Viewers, today we will learn how to create Ripple Effect Button using HTML and CSS. You easily create this button using HTML & CSS by following these tutorials and steps. You will build this button by just following this video tutorial or these steps which I am given below. In addition, common HTML and CSS programming codes have been used. It is designed in a completely modern way.

Some information about this Ripple Effect Button

Ripple effect is a part of the modern design trend. This button design, which uses beautiful colors & effects the best of beauty. this is shows a simple button. but when will I click this button then show ripple effect (wave effect). Ripple effect is a pretty cool animation and it is very popular in the world of design

Watch the video tutorial to create Ripple Effect Button

If you want to learn how to make it completely, you can watch the video tutorial below. Here I have shown how I made this design step by step. So you can learn how to make this Ripple effect button. This is a youtube video. If you can learn something from the video or if the video seems helpful to you, you must like and subscribe to the video. As a result, I get motivated to create other new designs.

Hopefully, the above video tutorial has helped you to create this button. If you like the video tutorial, be sure to like the video and comment on it so I can encourage you to create new designs.

You might like this:

Ripple Effect Button | Source Codes

You have to create HTML, CSS and JS File For this design. After creating these files just paste the following codes into your file.

First Step, create an HTML file with the name of index.html and paste the given codes in your HTML file. Remember, you’ve to create a file with .html extension and the images that are used on this website won’t appear.

HTML CODE:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Product Card Design</title>
    <!----css custom file link-->
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <div class="wrapper">
        <div class="wrapper-text">Button Ripple Effect</div>
        <p>Using HTML CSS AND JS</p>
        <div class="btns">
            <a href="#">Click Me</a>
            <a href="#">Click Me</a>
        </div>
    </div>


</body>
</html>

Second Step, you have to create a CSS file with the name of style.css and paste the given codes in your CSS file. Remember, you’ve to create a file with .css extension.

CSS CODE:

@import url("https://fonts.googleapis.com/css?family=Poppins:400,500,600,700&display=swap");

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

html,
body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.wrapper {
  padding: 3rem;
  box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.23);
  border-radius: 16px;
  -webkit-border-radius: 16px;
  text-align: center;
}

.wrapper .wrapper-text {
  font-size: 2rem;
  font-weight: 700;
}

.wrapper p {
  font-size: 20px;
  line-height: 20px;
  font-weight: 500;
}

.btns {
  display: flex;
  margin: 30px 0 20px 0;
}

.btns a {
  position: relative;
  margin: 0 20px;
  display: block;
  height: 60px;
  width: 200px;
  line-height: 60px;
  border-radius: 30px;
  -webkit-border-radius: 30px;
  color: white;
  text-decoration: none;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 18px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.23);
  overflow: hidden;
}

.btns a:first-child {
  background: linear-gradient(-90deg, #f5ce62, #e85a19);
}

.btns a:last-child {
  background: linear-gradient(90deg, #0162c8, #55e7fc);
}

.btns a > span {
  position: absolute;
  background: #fff;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  pointer-events: none;
  animation: ripples 0.6s linear infinite;
  -webkit-animation: ripples 0.6s linear infinite;
  border-radius: 50px;
  -webkit-border-radius: 50px;
}

@keyframes ripples {
  0% {
    width: 0px;
    height: 0px;
    opacity: 0.5;
  }
  100% {
    width: 500px;
    height: 500px;
    opacity: 0;
  }
}

third Step, you have to create a JS file with the name of js.js and paste the given codes in your JS file. Remember, you’ve to create a file with .js extension.

JS CODE:

const buttons = document.querySelectorAll("a");

buttons.forEach((button) => {
  button.onclick = function (e) {
    let x = e.clientX - e.target.offsetLeft;
    let y = e.clientY - e.target.offsetTop;
    let ripple = document.createElement("span");
    ripple.style.left = `${x}px`;
    ripple.style.top = `${y}px`;
    this.appendChild(ripple);
    setTimeout(() => {
      ripple.remove();
    }, 600);
  };
});

now you’ve successfully created this Ripple effect button using HTML, CSS and JS. If your code does not work or faced any error/problem to comment down or contact us through the contact page.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Categories