freecoding.school100% FREE · NO SIGNUP
Grid CanyonISSUE #22 of 27

responsive · viewport units · vw · vh · vmin · vmax

FlexboVSThe Float Phantom
Flexbo saysViewport units — vw, vh, vmin, vmax (and dvh) — size things relative to the screen.

1vw is 1% of viewport width, 1vh 1% of height; vmin/vmax track the smaller/larger dimension. Great for full-height heroes (height:100vh) and fluid type. On mobile, prefer the dynamic dvh unit, since 100vh can include the area under the address bar.

Power-ups you unlock

The Float Phantom attacks — common mistakes

Boss battleMake a full-viewport-height hero, then size a heading fluidly with clamp + vw.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.hero{height:100vh;display:grid;place-items:center;background:#140a28}.hero h1{font-size:clamp(24px,8vw,72px);color:#b388ff}</style></head><body style="margin:0;background:#06040d"><section class="hero"><h1>full-height hero</h1></section></body></html>
▶ Open the interactive comic issue
‹ Multi-Column · Column-Count · Column-RuleMedia Queries · Screen Sizes ›