CKTIS / CSS
Proprietà CSS `line-break`
`line-break` sceglie le opportunità di interruzione di riga consentite, soprattutto attorno a caratteri e punteggiatura CJK.
Versione: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review
Sintassi
auto | loose | normal | strict | anywhereline-break sceglie le opportunità di interruzione di riga consentite, soprattutto attorno a caratteri e punteggiatura CJK.
L’esempio confronta un riquadro stretto con strict e anywhere; il secondo valore può distribuire su sei righe una parola altrimenti indivisibile.
Grammatica: auto | loose | normal | strict | anywhere.
La proprietà è ereditata e il risultato dipende da lingua e sistema di scrittura dell’elemento. Le differenze fra loose, normal e strict riguardano soprattutto le regole CJK; anywhere aggiunge intenzionalmente molte più opportunità.
Esempi
<!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>Risultato
height=20->120; lines=1->6; computed=anywhere
L’esempio è stato eseguito localmente in una sessione Chrome isolata e senza rete; il risultato proviene dall’API CSS del browser.