CSS Fluid Layouts
CSS
What is a Fluid Layout?
A fluid layout is a layout that stretches and shrinks based on the size of the browser window or screen. It uses relative units (like %, vw, em) instead of fixed units (like px).
Why Use Fluid Layouts?
- Works on any screen size (mobile, tablet, desktop)
 - Eliminates horizontal scrolling
 - Keeps your design flexible and responsive
 
| Unit | What it means | 
|---|---|
| % | Relative to parent element | 
| vw | % of viewport width | 
| vh | % of viewport height | 
| em / rem | Relative to font size | 
Example 1: Fluid Container
This container adapts to screen size but stays readable on large screens.
Example 2: Fluid Image
Image scales smoothly on different devices.
Example 3: Fluid Columns
Columns adjust as the screen resizes.
Combine with Media Queries
Use media queries to improve fluid layouts on breakpoints:
| Feature | Benefit | 
|---|---|
| Relative units | Automatically adjust to screen size | 
| % & vw/vh | Ideal for flexible layouts | 
| Fluid images | Resize without distortion | 
| Combine with media queries | For better control |