liveBook · Manning

Fluid image

As explained in Web Design Playground, Second Edition

A fluid image is an image whose rendered dimensions adapt to available layout space while preserving its proportions and size constraints.

A fluid image changes size with the space available in its parent container while keeping its proportions intact. It helps a responsive page fit different screens without horizontal scrolling. section 14.7 section 14.0

Use the basic rule:

  • Set max-width: 100% so the image can shrink with its container but does not grow beyond its original width. section 14.7
  • Set height: auto so the browser calculates height from the current width and preserves the original aspect ratio. section 14.7
  • When height must not exceed the original, use max-height: 100% with width: auto instead. section 14.7

A small responsive image

img { max-width: 100%; height: auto; } As the image’s aside parent becomes narrower, the image scales down without distortion; it can scale smaller or larger, but not beyond its original dimensions. section 14.7

img {
    max-width: 100%;
    height: auto;
}

Inspect the minimal CSS rule that makes an image fluid. section 14.7

Fluid sizing does not require sending the same file everywhere. Combine responsive sizing with sizes and srcset when different devices should receive different image versions. section 14.8

How Web Design Playground, Second Edition covers it

How deep it goes
Explains width, height, aspect-ratio preservation, size limits, and responsive delivery, but stops short of advanced image optimization.
Examples
Uses an img rule, a responsive webpage aside, changing container widths, and small, medium, and large image files.
What you can do after
Build it from scratch with max-width and height auto, then deliver size-appropriate files through sizes and srcset.
How it connects
Connects responsive web design, parent containers, aspect ratios, sizes, and srcset.

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.