← CodePrimer
CSS Beginner Components

Simple CSS transition

How do I animate hover smoothly?

transition property.

Sample
.btn {
  background: #2563eb;
  transition: background 0.2s ease, transform 0.2s ease;
}
.btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

Notes

Animate transform/opacity for smoother performance.

Keywords: transition · animation · hover

Related

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share