Button Hover Effect | HTML | CSS | JS

Hover Effect Button

<!-- HTML -->
<button class="hover-button">Hover Me!</button>

/* CSS */
.hover-button {
    padding: 15px 30px;
    font-size: 18px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.hover-button:hover {
    background-color: #2980b9;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
        

Explanation:

  1. The button uses a transition property to create smooth animations.
  2. On hover, three effects occur:
    • Background color darkens
    • Button scales up by 10%
    • Shadow appears for depth
  3. The cursor: pointer property changes the cursor to a hand when hovering.
  4. Border-radius adds rounded corners to the button.

Try it yourself:

Post a Comment

0 Comments