Baza znanjaCentar za ispite
HRHrvatski
Odaberi jezik13

CKTIS / CSS

CSS svojstvo `line-break`

`line-break` odabire dopuštena mjesta prijeloma retka, osobito uz CJK znakove i interpunkciju.

Verzija: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Sintaksa

auto | loose | normal | strict | anywhere

line-break odabire dopuštena mjesta prijeloma retka, osobito uz CJK znakove i interpunkciju.

Primjer uspoređuje uski okvir s vrijednostima strict i anywhere; druga može inače nedjeljivu riječ rasporediti u šest redaka.

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

Svojstvo se nasljeđuje, a rezultat ovisi o jeziku i pismu elementa. Razlike između loose, normal i strict uglavnom se odnose na CJK pravila; anywhere namjerno dodaje mnogo više mjesta prijeloma.

Primjeri

<!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

Primjer je izveden lokalno u izoliranoj Chrome sesiji bez mreže; rezultat dolazi iz preglednikovog CSS API-ja.

Izvori