sdxc

[ @sdxc/u/layout ]

position

Sets position: relative.

import { relative } from "@sdxc/u/layout";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.relative()css({ position: "relative" })

Examples

Basic example

Use relative() to position an element in the normal flow, so its absolutely positioned children are offset from it:

Relative parent

absolute()
<div mix={[relative(), is(72), bs(36), ...]}>
	<p>Relative parent</p>
	<div mix={[absolute(), insBs(3), insIe(3), ...]}>absolute()</div>
</div>

Offsetting in the flow

Add offsets like insBs(4) and insIs(6) to shift a relative element from its place, while the space it came from stays reserved:

relative()
<div mix={[...]}>
	<div mix={[relative(), insBs(4), insIs(6), ...]}>relative()</div>
</div>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

u.hover(u.relative())

Responsive design

Wrap the call in a container query to scope it to one width.

u.at("md", u.relative())

Signature

u.relative()

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.