8 simplest CSS hover effects

CSS3 Hover Effects for Engaging Buttons

With growing support for CSS3 across modern browsers and the decline of CSS2-only browsers, developers now have a wide range of options for creating engaging hover effects and transitions. These effects are commonly used in calls to action (CTAs) to draw attention and enhance user interaction. This guide explores eight simple CSS3 hover effects, building on a previous article featuring 8 simple transitions.

Getting Started

We’ll use a simple HTML button as the base for our effects:

<button>Hover Me</button>
    

Below is the core CSS applied to all buttons, setting defaults like background color, font size, and a global transition for smooth animations:

button {
  border: none;
  background: #3a7999;
  color: #f2f2f2;
  padding: 10px;
  font-size: 18px;
  border-radius: 5px;
  position: relative;
  box-sizing: border-box;
  transition: all 500ms ease;
}
    

1. Horizontal Immersion

This effect uses a semi-transparent overlay that slides in from the left on hover, creating an immersive effect.

Use the :before pseudo-element to create the overlay:

button:before {
  content: '';
  position: absolute;
  top: 0px;
  left: 0px;
  width: 0px;
  height: 42px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  transition: all 2s ease;
}
button:hover:before {
  width: 100%;
}
    

2. Vertical Immersion

Similar to the horizontal effect, this overlay slides down from the top on hover.

button:before {
  content: '';
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 0px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  transition: all 2s ease;
}
button:hover:before {
  height: 42px;
}
    

3. Ghost Button

This effect inverts the button’s colors and adds a solid border on hover, creating a “ghost” appearance.

button:hover {
  background: rgba(0, 0, 0, 0);
  color: #3a7999;
  box-shadow: inset 0 0 0 3px #3a7999;
}
    

4. Icon Animate In

An icon (e.g., a cart) slides in from the left on hover, ideal for actions like adding to a cart. Requires Font Awesome.

button {
  padding: 10px 35px;
  overflow: hidden;
}
button:before {
  font-family: FontAwesome;
  content: "\f07a";
  position: absolute;
  top: 11px;
  left: -30px;
  transition: all 200ms ease;
}
button:hover:before {
  left: 7px;
}
    

5. Bounce Effect

This effect uses keyframes to create a bouncing animation on hover, drawing user attention.

@keyframes bounce {
  0%, 20%, 60%, 100% {
    -webkit-transform: translateY(0);
    transform: translateY(0);
  }
  40% {
    -webkit-transform: translateY(-20px);
    transform: translateY(-20px);
  }
  80% {
    -webkit-transform: translateY(-10px);
    transform: translateY(-10px);
  }
}
button:hover {
  animation: bounce 1s;
}
    

6. Skew

The skew transform tilts the button on hover for a dynamic effect.

button:hover {
  transform: skew(-10deg);
}
    

7. Dotted Border

Similar to the ghost button, this effect switches to a dotted border on hover.

button {
  border: 3px solid #3a7999;
}
button:hover {
  border: 3px dotted #3a7999;
  color: #3a7999;
  background: rgba(0, 0, 0, 0);
}
    

8. Flip 3D Effect

This effect flips the button to reveal a new message using the :after pseudo-element.

button {
  transform-style: preserve-3d;
}
button:after {
  top: -100%;
  left: 0px;
  width: 100%;
  position: absolute;
  background: #3a9999;
  border-radius: 5px;
  content: 'Flipped';
  transform-origin: left bottom;
  transform: rotateX(90deg);
}
button:hover {
  transform-origin: center bottom;
  transform: rotateX(-90deg) translateY(100%);
}
    

The button uses preserve-3d to maintain 3D positioning, with the :after element rotated 90 degrees and flipped on hover.

Related posts