css button hover effect | button hover effect







css button hover effect | button hover effect

WelcomeğŸŽ‰ to codewithrandom blog in this blog we learn that how we create css button hover effect . We use HTML & css  for this css button hover effect.  Hope you enjoy our blog so let’s start with a basic HTML structure for css button hover effect.

HTML code 

 <!DOCTYPE html>  
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="btn">
<Button>Hover Me!</Button>
<div class="box"></div>
<div class="box2"></div>
</div>
</body>
</html>

There is all HTML code for css button hover effect . Now you can see output without css then we write css for our css button hover effect.

 @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');  
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.btn{
width: 130px;
height: 40px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.btn button{
position: absolute;
width: 100%;
height: 100%;
border: none;
background: rgba(255, 255, 255, 0);
backdrop-filter: blur(20px);
color: rgba(0, 0, 0, 0.884);
cursor: pointer;
font-size: .95em;
transition: all .4s;
border-radius: 20px;
}
.btn button:hover{
color: white;
}
.box,.box2{
content: '';
position: absolute;
top: 10%;
left: -1.5%;
width: 100%;
height: 100%;
background: none;
z-index: -2;
border: 5px solid #0099f7;
border-radius: 20px;
transition: all .4s;
}
.btn button:hover ~ .box{
background: #f11712;
border: 5px solid #f11712;
top: -10%;
left: 1.5%;
}

Now we complete our css section,  Here is our updated output with css.


css button hover effect | button hover effect
In this post, we learn how to create  css button hover effect with simple coding of HTML & css . If we did a mistake or any confusion please drop a comment so give a reply or help you in easy learning.
project: by @coding_gyan_
written by – codewithrandom/Anki 


Share on:

Leave a Comment