文本的行高,最少 2 行文本

line-height on text with minimum 2 lines of text

我有办法添加 line-hight:22px; 任何有两行或更多行的文本。 但不影响不进入第二行的文本?

有没有办法只在 css 中实现这个?

您可以使用纯 CSS,但请注意 IE8 及以下版本。这是 browser support.

.class {
    line-height: 22px;
}

.class::first-line {
    line-height: 1;
}

这是做什么的,它将所有内容设置为 22px 的 line-height,但将第一行重置为 1 的 line-height,您也可以使用 100% 等。这应该可以满足您的需求想要实现。