CKTIS / CSS
CSS svojstvo `justify-content`
`justify-content` raspodjeljuje slobodan prostor između i oko flex stavki ili grid staza na glavnoj ili linijskoj osi.
Verzija: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Sintaksa
normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ]justify-content raspodjeljuje slobodan prostor između i oko flex stavki ili grid staza na glavnoj ili linijskoj osi.
Primjer uspoređuje položaj prve stavke pri start i center u flex spremniku stalne širine.
Gramatika: normal | <content-distribution> | <overflow-position>? [ <content-position> | left | right ].
Bez slobodnog prostora nema pomaka; ne zamjenjuje justify-self, a sigurno poravnanje može se vratiti prema start.
Primjeri
<!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>Rezultat
first-x=0->40; computed=center
Primjer je izveden lokalno u izoliranoj Chrome sesiji bez mreže; rezultat dolazi iz preglednikovog CSS API-ja.