CKTIS / CSS
Vlastnost CSS `justify-content`
`justify-content` rozděluje volné místo mezi položky flex či stopy grid a kolem nich na hlavní nebo řádkové ose.
Verze: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Syntaxe
normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ]justify-content rozděluje volné místo mezi položky flex či stopy grid a kolem nich na hlavní nebo řádkové ose.
Příklad porovná polohu první položky při start a center ve flex kontejneru pevné šířky.
Gramatika: normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ].
Bez volného místa nedojde k posunu; vlastnost nenahrazuje justify-self a bezpečné zarovnání může ustoupit ke start.
Příklady
<!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>Výsledek
first-x=0->40; computed=center
Příklad byl spuštěn místně v izolované relaci Chrome bez sítě; výsledek pochází z CSS API prohlížeče.