CKTIS / CSS
CSS-eigenschap `justify-content`
`justify-content` verdeelt vrije ruimte tussen en rond flexitems of gridsporen op de hoofd- of inline-as.
Versie: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Syntax
normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ]justify-content verdeelt vrije ruimte tussen en rond flexitems of gridsporen op de hoofd- of inline-as.
Het voorbeeld vergelijkt de positie van het eerste item bij start en center in een flexcontainer met vaste breedte.
Grammatica: normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ].
Zonder vrije ruimte is er geen verschuiving; dit vervangt justify-self niet en veilige uitlijning kan naar start terugvallen.
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");g.innerHTML="<i></i><i></i>";document.body.prepend(g);g.style.cssText="display:flex;width:120px;height:40px";for(const x of g.children)x.style.cssText="width:20px;height:10px";const a=g.getBoundingClientRect();g.style.justifyContent="start";const x0=Math.round(g.firstElementChild.getBoundingClientRect().left-a.left);g.style.justifyContent="center";const x1=Math.round(g.firstElementChild.getBoundingClientRect().left-a.left);document.querySelector("#result").textContent="first-x="+x0+"->"+x1+"; computed="+getComputedStyle(g).justifyContent;</script></body></html>Resultaat
first-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.