SyntaxStudy
Sign Up
CSS Transitioning Opacity
CSS Intermediate 4 min read

Transitioning Opacity

Opacity Transitions

Transitioning opacity is the standard way to fade elements in and out. Combined with pointer-events, it can create accessible show/hide patterns.

Example
.tooltip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.trigger:hover .tooltip,
.trigger:focus .tooltip {
  opacity: 1;
  pointer-events: auto;
}

/* Fade in on load */
.fade-in {
  animation: none;
  opacity: 0;
  transition: opacity 0.5s ease 0.1s;
}
.fade-in.visible { opacity: 1; }
Pro Tip

Use opacity + pointer-events instead of display:none/block when you want to transition visibility.