Skip to main content

Background Size

Set the background image size within an element.

View as Markdown
baselinewidely
ClassCSS
bs:autobackground-size: auto;
bs:cbackground-size: cover;
bs:cobackground-size: contain;

Variants

Prefix any class with a variant to apply it only under that condition. Variants stack, as in @md:h:bs:c.

Breakpoints

Apply a class from a viewport width up. Each breakpoint covers its width & every width above it.

@xs:bs:cFrom 32rem up.
@sm:bs:cFrom 40rem up.
@md:bs:cFrom 48rem up.
@lg:bs:cFrom 64rem up.
@xl:bs:cFrom 80rem up.
@xxl:bs:cFrom 96rem up.

Containers

Apply a class from a container's width up, not the viewport's. Mark the parent with ct:is first.

@c:xs:bs:cContainer from 32rem up.
@c:sm:bs:cContainer from 40rem up.
@c:md:bs:cContainer from 48rem up.
@c:lg:bs:cContainer from 64rem up.
@c:xl:bs:cContainer from 80rem up.
@c:xxl:bs:cContainer from 96rem up.

Media

Apply a class when the device or the page matches a condition, or on the first frame an element renders.

@pc:bs:cOn a touch screen.
@prm:bs:cWith reduced motion on.
@st:bs:cOn the first frame.

States

Apply a class only while the element is in a state, such as hovered, focused or checked.

h:bs:cOn :hover.
f:bs:cOn :focus.
fv:bs:cOn :focus-visible.
a:bs:cOn :active.
d:bs:cOn :disabled.
fc:bs:cOn :first-child.
c:bs:cOn :checked.
e:bs:cOn :empty.
fw:bs:cOn :focus-within.
i:bs:cOn :invalid.
in:bs:cOn :indeterminate.
lc:bs:cOn :last-child.
nc:bs:cOn :nth-child.
r:bs:cOn :required.
ro:bs:cOn :read-only.
v:bs:cOn :valid.

Pseudo Elements

Style a part of the element rather than the element itself, such as its placeholder or the selected text.

a::bs:cOn ::after.
b::bs:cOn ::before.
p::bs:cOn ::placeholder.
s::bs:cOn ::selection.