Bootstrap includes an incredibly fast toolkit of shorthand helper CSS utility classes structurally dedicated exclusively perfectly to sizing HTML components block-by-block. Instead of writing custom width limits inside CSS files natively, you simply quickly apply responsive classes directly matching proportion fractions!
Width utility classes explicitly force elements to specifically calculate their total physical horizontal expanse proportionally exactly relative strictly to their immediate structural parent element.
.w-25 (25% Width).w-50 (50% Width).w-75 (75% Width).w-100 (100% Width).w-auto (Width calculates automatically correctly relying gracefully upon inner content!)<!-- Width forces perfectly to precisely 50% relative to whatever container explicitly houses it! -->
<div class="w-50 p-3 bg-light">I am strictly natively 50% wide</div>
<!-- Forces element exactly unconditionally natively to 100% width -->
<div class="w-100 p-3 bg-light">I am specifically spanning perfectly the entire block entirely.</div>
Height utilities behave exactly cleanly structurally identical mathematically to widths universally! It relies heavily exclusively precisely on `.h-25`, `.h-50`, `.h-75`, `.h-100`, and natively `.h-auto`!
Crucial Rule: CSS percentage-based heights strictly purely function explicitly *only* if the underlying native parent wrapper unequivocally maintains a rigidly defined explicit exact CSS height previously organically established! If the parent dynamically calculates natively off text lines alone exclusively natively perfectly magically structurally height calculations will utterly fail natively securely!
<!-- Parent MUST natively define secure absolute height -->
<div style="height: 200px;">
<div class="h-50">Height exactly organically hits 100px uniformly! (50% cleanly mathematically of 200px)</div>
<div class="h-100">Height forces magically strictly straight directly precisely to identically mathematically 200px!</div>
</div>
Bootstrap includes `.mw-100` (`max-width: 100%`) and critically explicitly `.mh-100` (`max-height: 100%`). This acts exactly structurally precisely entirely perfectly securely defensively natively! For example securely entirely, applying securely `.mw-100` to heavily absolutely gigantic resolution identically magically images ensures structurally natively absolutely heavily they will violently shrink securely exactly strictly preventing them massively violently exclusively from blowing structurally out purely specifically cleanly past their containing strictly specific bounding wrappers!
<!-- Image powerfully securely restricts exclusively exactly native scaling cleanly to maximum 100% structurally cleanly precisely! -->
<img src="massive-10k-image.jpg" class="mw-100" alt="Responsive scaling purely visually exclusively!">
Sometimes you don't want an element to size itself based on its parent container. Instead, you want it to size itself based on the user's actual screen size (the "viewport"). Bootstrap provides viewport classes specifically for this.
.vw-100 - Forces the element's width to be exactly 100% of the screen's width..vh-100 - Forces the element's height to be exactly 100% of the screen's height. This is perfect for creating full-screen landing pages or hero sections..min-vh-100 - Sets the minimum height to 100% of the screen. This is incredibly useful because it guarantees the element will take up the whole screen, but if you add a massive amount of text inside it, the element is allowed to flexibly grow taller than the screen so the text doesn't overflow and break!<!-- Create a perfect full-screen landing page hero section! -->
<header class="vh-100 bg-dark text-white d-flex align-items-center justify-content-center">
<h1>I take up exactly 100% of your screen's height!</h1>
</header>