排版
控制元素行距或行高的工具类。
Class | Styles |
---|---|
text-<size>/<number> | font-size: <size>;
line-height: calc(var(--spacing) * <number>); |
text-<size>/(<custom-property>) | font-size: <size>;
line-height: var(<custom-property>); |
text-<size>/[<value>] | font-size: <size>;
line-height: <value>; |
leading-none | line-height: 1; |
leading-<number> | line-height: calc(var(--spacing) * <number>) |
leading-(<custom-property>) | line-height: var(<custom-property>); |
leading-[<value>] | line-height: <value>; |
使用字体大小工具类如 text-sm/6
和 text-lg/7
同时设置元素的字体大小和行高:
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
<p class="text-base/6 ...">所以我开始走进水中...</p><p class="text-base/7 ...">所以我开始走进水中...</p><p class="text-base/8 ...">所以我开始走进水中...</p>
每个字体大小工具类在没有提供行高时也会设置一个默认的行高。有关这些值及如何自定义它们的更多信息,请查看 字体大小文档。
使用 leading-<number>
工具类如 leading-6
和 leading-7
来独立于字体大小设置元素的行高:
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
所以我开始走进水中。我不会对你们撒谎,伙计们,我很害怕。但我坚持下去了,当我穿过海浪时,一种奇怪的平静笼罩了我。我不知道这是神的干预还是所有生物的亲密关系,但我告诉你,杰瑞,在那一刻,我 就是 一名海洋生物学家。
<p class="text-sm leading-6">所以我开始走进水中...</p><p class="text-sm leading-7">所以我开始走进水中...</p><p class="text-sm leading-8">所以我开始走进水中...</p>
使用 leading-none
工具类将元素的行高设置为与其字体大小相等:
机敏的棕色狐狸跳过懒狗。
<p class="text-2xl leading-none ...">机敏的棕色狐狸...</p>
Use the leading-[<value>]
syntax to set the 行高 based on a completely custom value:
<p class="leading-[1.5] ..."> Lorem ipsum dolor sit amet...</p>
For CSS variables, you can also use the leading-(<custom-property>)
syntax:
<p class="leading-(--my-line-height) ..."> Lorem ipsum dolor sit amet...</p>
This is just a shorthand for leading-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a line-height
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<p class="leading-5 md:leading-6 ..."> Lorem ipsum dolor sit amet...</p>
Learn more about using variants in the variants documentation.
The leading-<number>
utilities are driven by the --spacing
theme variable, which can be customized in your own theme:
@theme { --spacing: 1px; }
Learn more about customizing the spacing scale in the theme variable documentation.