Skip to main content

Object Fit

Set how to resize the content of a replaced element.

View as Markdown
baselinewidely
ClassCSS
of:cobject-fit: cover;
of:fobject-fit: fill;
of:noneobject-fit: none;
of:sdobject-fit: scale-down;

Variants

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

Breakpoints

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

@xs:of:noneFrom 32rem up.
@sm:of:noneFrom 40rem up.
@md:of:noneFrom 48rem up.
@lg:of:noneFrom 64rem up.
@xl:of:noneFrom 80rem up.
@xxl:of:noneFrom 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:of:noneContainer from 32rem up.
@c:sm:of:noneContainer from 40rem up.
@c:md:of:noneContainer from 48rem up.
@c:lg:of:noneContainer from 64rem up.
@c:xl:of:noneContainer from 80rem up.
@c:xxl:of:noneContainer 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:of:noneOn a touch screen.
@prm:of:noneWith reduced motion on.
@st:of:noneOn the first frame.

States

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

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

Pseudo Elements

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

a::of:noneOn ::after.
b::of:noneOn ::before.
p::of:noneOn ::placeholder.
s::of:noneOn ::selection.