CKTIS / CSS
CSS-eigenschap `justify-items`
`justify-items` stelt de standaard justify-self van griditems op de inline-as van hun gebieden in.
Versie: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Syntax
normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ] | anchor-centerjustify-items stelt de standaard justify-self van griditems op de inline-as van hun gebieden in.
Het voorbeeld verplaatst een echt gridkind van start naar center en meet de x-coördinaat.
Grammatica: normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ] | anchor-center.
justify-self van het kind overschrijft de waarde; in flexbox positioneert justify-items geen flexitems.
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";x.style.cssText="width:20px;height:10px";const a=g.getBoundingClientRect();g.style.justifyItems="start";const x0=Math.round(x.getBoundingClientRect().left-a.left);g.style.justifyItems="center";const x1=Math.round(x.getBoundingClientRect().left-a.left);document.querySelector("#result").textContent="child-x="+x0+"->"+x1+"; computed="+getComputedStyle(g).justifyItems;</script></body></html>Resultaat
child-x=0->40; 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.