Hover Transitions
Hover transitions are the most common use case. Define base styles on the element and changed styles on :hover. The transition runs both ways automatically.
Hover transitions are the most common use case. Define base styles on the element and changed styles on :hover. The transition runs both ways automatically.
.nav-link {
color: #555;
border-bottom: 2px solid transparent;
transition: color 0.2s, border-color 0.2s;
padding-bottom: 4px;
}
.nav-link:hover {
color: #007bff;
border-bottom-color: #007bff;
}
Transitions reverse automatically when the trigger state is removed — no need to define the reverse transition separately.