Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / CSS

Lastnost CSS `line-break`

`line-break` izbere dovoljena mesta preloma vrstice, zlasti ob znakih in ločilih CJK.

Različica: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Sintaksa

auto | loose | normal | strict | anywhere

line-break izbere dovoljena mesta preloma vrstice, zlasti ob znakih in ločilih CJK.

Primer primerja ozko polje z vrednostma strict in anywhere; druga lahko sicer nedeljivo besedo razporedi v šest vrstic.

Slovnica: auto | loose | normal | strict | anywhere.

Lastnost se deduje, rezultat pa je odvisen od jezika in pisave elementa. Razlike med loose, normal in strict se nanašajo predvsem na pravila CJK; anywhere namenoma doda veliko več možnosti preloma.

Primeri

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>line-break behavior</title>
<body><div id="probe">ABCDEFGHIJKLMN</div><pre id="result"></pre><script>
const probe=document.querySelector('#probe');probe.lang='en';probe.style.cssText='display:inline-block;width:32px;font:16px/20px sans-serif;line-break:strict';
const strict=Math.round(probe.getBoundingClientRect().height);probe.style.lineBreak='anywhere';const anywhere=Math.round(probe.getBoundingClientRect().height);
document.querySelector('#result').textContent='height='+strict+'->'+anywhere+'; lines='+strict/20+'->'+anywhere/20+'; computed='+getComputedStyle(probe).lineBreak;
</script></body></html>

Rezultat

height=20->120; lines=1->6; computed=anywhere

Primer je bil izveden lokalno v izolirani seji Chrome brez omrežja; rezultat prihaja iz brskalnikovega API CSS.

Viri