KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / CSS

CSS-eigenschap `justify-self`

`justify-self` lijnt één griditem of gepositioneerd vak op de inline-as binnen zijn gebied uit.

Versie: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | anchor-center

justify-self lijnt één griditem of gepositioneerd vak op de inline-as binnen zijn gebied uit.

Het voorbeeld houdt justify-items:start op de container en verplaatst alleen het geteste kind naar center.

Grammatica: auto | normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | anchor-center.

Het lijnt geen flexitem op de hoofdas uit; auto volgt meestal de container en stretch vereist een automatische maat.

Voorbeelden

<!doctype html><html lang="en"><meta charset="utf-8"><title>CKTIS CSS example</title><body><pre id="result"></pre><script>const g=document.createElement("div"),x=document.createElement("i");document.body.prepend(g);g.append(x);g.style.cssText="display:grid;width:100px;height:40px;grid-template-columns:100px;justify-items:start";x.style.cssText="width:20px;height:10px";const a=g.getBoundingClientRect(),x0=Math.round(x.getBoundingClientRect().left-a.left);x.style.justifySelf="center";const x1=Math.round(x.getBoundingClientRect().left-a.left);document.querySelector("#result").textContent="child-x="+x0+"->"+x1+"; container="+getComputedStyle(g).justifyItems+"; computed="+getComputedStyle(x).justifySelf;</script></body></html>

Resultaat

child-x=0->40; container=start; computed=center

Het voorbeeld is lokaal uitgevoerd in een geïsoleerde Chrome-sessie zonder netwerk; het resultaat komt uit de CSS-API van de browser.

Bronnen