liveBook · Manning

Transition

As explained in Web Design Playground, Second Edition

The CSS transition property specifies animated changes between values of other CSS properties.

A CSS transition makes a change happen gradually instead of all at once. Think of it as a gentle fade rather than a light switch: when an image overlay changes opacity, the browser animates that change. section 20.5

Fade in an overlay

Set the overlay to start invisible with opacity: 0, then use transition: opacity 1.5s ease. On hover, changing opacity to 1 fades the after image into view over the before image. section 20.5

.image-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 200px;
  height: 156px;
  z-index: 1;
  opacity: 0;
  transition: opacity 1.5s ease;
}
.image-overlay:hover {
  opacity: 1;
}

This CSS pairs an opacity change with a 1.5-second eased transition, then triggers the visible state on hover. section 20.5

How Web Design Playground, Second Edition covers it

How deep it goes
Demonstrates a complete opacity transition rule without detailing transition syntax beyond the example.
Examples
Uses before-and-after book restoration images, with an after image fading in over the original.
What you can do after
Apply it via CSS to fade an overlay into view when it is hovered.
How it connects
Connects transition with opacity, hover, absolute positioning, relative positioning, and z-index.

Also explained in

Compare how 5 books explain transition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.