試一試
tab-size: 10px;
tab-size: 16px;
tab-size: 24px;
tab-size: 4;
<section id="default-example">
<pre id="example-element">	123</pre>
</section>
#example-element {
border: 1px solid;
}
語法
css
/* <number> values */
tab-size: 4;
tab-size: 0;
/* <length> values */
tab-size: 10px;
tab-size: 2em;
/* Global values */
tab-size: inherit;
tab-size: initial;
tab-size: revert;
tab-size: revert-layer;
tab-size: unset;
值
正式定義
正式語法
tab-size =
<number [0,∞]> |
<length [0,∞]>
示例
按字元數展開
css
pre {
tab-size: 4; /* Set tab size to 4 characters wide */
}
摺疊製表符
css
pre {
tab-size: 0; /* Remove indentation */
}
預設製表符大小與自定義大小
此示例比較了預設製表符大小和自定義製表符大小。請注意,white-space 設定為 pre 以防止製表符摺疊。
HTML
html
<p>no tab</p>
<p>	default tab size of 8 characters wide</p>
<p class="custom-number">	custom tab size of 3 characters wide</p>
<p> 3 spaces, equivalent to the custom tab size</p>
<p class="custom-length">	custom tab size of 50px wide</p>
CSS
css
p {
white-space: pre;
}
.custom-number {
tab-size: 3;
}
.custom-length {
tab-size: 50px;
}
結果
規範
| 規範 |
|---|
| CSS Text Module Level 3 # tab-size-property |
瀏覽器相容性
載入中…