Posted on Jan. 28, 2021, 8 p.m. by Bishal ( 2812)
<button>
is an element used to create a clickable buttons. The button created in this tutorial gives visitors an attractive animated button made with HTML and CSS.
index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>Animated Button - Code With Bishal</title>
</head>
<!-- created by Code With Bishal - www.codewithbishal.com
-->
<body>
</body>
</html>
style.css
<head> </head>
of your HTML document:<link rel="stylesheet" href="style.css">
style.css
file.button {
border-radius: 4px;
background-color: #9933ff; /* change this to change the background colour of button */
border: none;
color: #fff; /* change this to change the colour of text */
text-align: center;
font-size: 28px; /* change this to change the font size of the text */
padding: 20px;
width: 300px; /* change the width of the button */
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span::after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span::after {
opacity: 1;
right: 0;
}
<!DOCTYPE html>
<html>
<head>
<title>Animated Button by Code With Bishal</title>
</head>
<body>
<button class="button"><span>Button With Animation </span> </button>
</body>
</html>
.button {
border-radius: 4px;
background-color: #9933ff; /* change this to change the background colour of button */
border: none;
color: #fff; /* change this to change the colour of text */
text-align: center;
font-size: 28px; /* change this to change the font size of the text */
padding: 20px;
width: 300px; /* change the width of the button */
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span::after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span::after {
opacity: 1;
right: 0;
}