buttons hover effect css code example

Example 1: no hover effect css

pointer-events:none;

Example 2: css a href hover effect

/* css code */
body{
   background-color: #000;
}
.container{            
   top: 50%;
   left: 50%;
   transform: translateX(-50%) translateY(-50%);
   position: absolute;
}
li{
   list-style: none;
   display: inline-block;
}
a{
   text-decoration: none;
   color:#fff;
   font-size: 24px;
   padding: 0 20px;
   display: inline-block;
}
.link::after{
   content: '';
   display: block;
   width: 0;
   height: 2px;
   transition: width .3s;
   background-color: #fff;
}
.link:hover::after{
   width: 100%;
   transition: width .3s;
}

/* html code */
<div class="container">
    <li><a href="#" class="link">Home</a></li>
    <li><a href="#" class="link">About Us</a></li>
    <li><a href="#" class="link">Services</a></li>
    <li><a href="#" class="link">Gallery</a></li>
    <li><a href="#" class="link">Contact</a></li>
</div>

Example 3: how to add animation to a button hover

.btn {
  background-color: #ddd;
  border: none;
  color: black;
  padding: 16px 32px;
  text-align: center;
  font-size: 16px;
  margin: 4px 2px;
  transition: 0.3s;
}

.btn:hover {
  background-color: #3e8e41;
  color: white;
}

Tags:

Html Example