Background Size
Controls the size of the background image of an element.
Widely available
This feature is well established and works across many devices and browser versions.
Chrome
Edge
Firefox
Safari
| Class | Style |
|---|---|
bs-auto | background-size: auto; |
bs-c | background-size: cover; |
bs-co | background-size: contain; |
Auto
Initial value
The background image retains its original size.
<div class="d-30"> <div class="bs-auto bp-c h-30" style="background-image:url(/img/lighthouse.jpg)"></div></div>Cover
The background image will cover the entire element.
<div class="d-30"> <div class="bs-c bp-c h-30" style="background-image:url(/img/lighthouse.jpg)"></div></div>Contain
The background image will be scaled to fit within the element.
<div class="d-30"> <div class="bs-co bp-c h-30" style="background-image:url(/img/lighthouse.jpg)"></div></div>Using utility variants
Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.
Targeting different viewports
You can combine responsive breakpoints like sm:bs-*, md:bs-*, lg:bs-*, and xxl:bs-* to allow targeting specific utilities in different viewports.
Targeting hover states
Alternatively, you can apply :hover by using h:bs-* utility to override elements and change their values when hovering over them.