Basic example
* { box-sizing: border-box; }
.card { width: 20rem; padding: 1rem; border: 1px solid #cbd5e1; }
Every element is a box. From inside out: content, padding, border, margin. Prefer box-sizing: border-box so width includes padding and border.
* { box-sizing: border-box; }
.card { width: 20rem; padding: 1rem; border: 1px solid #cbd5e1; }* { box-sizing: border-box; }
.card { width: 20rem; padding: 1rem; border: 1px solid #cbd5e1; }* { box-sizing: border-box; }
.card { width: 20rem; padding: 1rem; border: 1px solid #cbd5e1; }Box Model is a modern CSS feature.
Supported in current major browsers with progressive enhancement.
Bottom line: Keep a readable fallback when using newer syntax.
Continue with Containing Block.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
2 people found this page helpful