CKTIS / CSS
CSS-Eigenschaft `justify-items`
`justify-items` setzt den Standardwert von justify-self für Grid-Elemente auf der Inlineachse ihrer Bereiche.
Version: 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 setzt den Standardwert von justify-self für Grid-Elemente auf der Inlineachse ihrer Bereiche.
Das Beispiel verschiebt ein echtes Grid-Kind von start nach center und misst seine x-Koordinate.
Grammatik: normal | stretch | <baseline-position> | <overflow-position>? [ <self-position> | left | right ] | legacy | legacy && [ left | right | center ] | anchor-center.
justify-self am Kind überschreibt den Standard; in Flexbox positioniert justify-items keine Flex-Elemente.
Beispiele
<!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>Ergebnis
child-x=0->40; computed=center
Das Beispiel lief lokal in einer isolierten Chrome-Sitzung ohne Netzwerk; das Ergebnis stammt aus der CSS-API des Browsers.