试一试
line-break: auto;
line-break: anywhere;
line-break: normal;
line-break: loose;
<section id="default-example">
<p id="example-element">
この喫茶店は、いつでもコーヒーの香りを漂わせています。<br />彼女はこの喫茶店で働いて、着々と実力をつけていきました。<br />今では知る人ぞ知る、名人です。
</p>
</section>
#example-element {
font-family: "Yu Gothic", "YuGothic", "Meiryo", "MS ゴシック", sans-serif;
border: 2px dashed #999999;
text-align: left;
width: 240px;
font-size: 16px;
}
语法
css
/* Keyword values */
line-break: auto;
line-break: loose;
line-break: normal;
line-break: strict;
line-break: anywhere;
/* Global values */
line-break: inherit;
line-break: initial;
line-break: revert;
line-break: revert-layer;
line-break: unset;
值
正式定义
正式语法
line-break =
auto |
loose |
normal |
strict |
anywhere
示例
设置文本换行
查看文本是否在“々”、“ぁ”和“。”之前换行。
HTML
html
<div lang="ja">
<p class="wrap-box auto">
auto:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。
</p>
<p class="wrap-box loose">
loose:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。
</p>
<p class="wrap-box normal">
normal:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。
</p>
<p class="wrap-box strict">
strict:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。
</p>
<p class="wrap-box anywhere">
anywhere:<br />そこは湖のほとりで木々が輝いていた。<br />その景色に、美しいなぁと思わずつぶやいた。
</p>
</div>
CSS
css
.wrap-box {
width: 10em;
margin: 0.5em;
white-space: normal;
vertical-align: top;
display: inline-block;
}
.auto {
line-break: auto;
}
.loose {
line-break: loose;
}
.normal {
line-break: normal;
}
.strict {
line-break: strict;
}
.anywhere {
line-break: anywhere;
}
结果
规范
| 规范 |
|---|
| CSS Text Module Level 3 # line-break-property |
浏览器兼容性
加载中…