Znalostná bázaCentrum skúšok
SKSlovenčina
Vybrať jazyk13

CKTIS / CSS

grid-template-areas — vlastnosť CSS

`grid-template-areas` určuje mapu pomenovaných oblastí v rozložení grid.

Verzia: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

none | <string>+

grid-template-areas určuje mapu pomenovaných oblastí v rozložení grid.

Použite ju, keď veľkosť stopy alebo umiestnenie musí sledovať explicitné čiary; príklad meria súradnice a rozmery.

Prijímaná gramatika je none | <string>+; globálne hodnoty zostávajú v kaskáde.

Čiary začínajú číslom 1, záporné čísla sa počítajú od konca explicitnej mriežky a skratky môžu resetovať automatické umiestnenie.

Príklady

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>CKTIS CSS reference example</title>
<body><div class="probe">probe</div><pre id="result"></pre><script>
document.body.innerHTML='<div id="g"><i id="x"></i></div><pre id="result"></pre>';const g=document.querySelector("#g"),x=document.querySelector("#x");g.style.cssText="display:grid;grid-template-columns:30px 40px;grid-template-rows:20px";g.style.gridTemplateAreas=`"a b"`;x.style.gridArea="b";const a=g.getBoundingClientRect(),b=x.getBoundingClientRect();document.querySelector("#result").textContent="item-x="+Math.round(b.left-a.left)+"; computed="+getComputedStyle(g).gridTemplateAreas;
</script></body></html>

Výsledok

item-x=30; computed="a b"

Príklad bol spustený lokálne v izolovanej relácii Chrome bez siete; výsledok pochádza z CSS API prehliadača.

Zdroje