3

我已经有以下风格:white-space: pre-wrap;

这允许将换行符视为元素的换行符(并且空格不会折叠)。

现在我想申请text-indent: -40px; padding-left: 40px;尝试产生这样的东西:

This is a long line of text (or at least, just pretend it is) so it  
        will indent when it wraps.
Further lines of text appear as normal, but again if they exceed the
        maximum width then they wrap and indent.

不幸的是,它并没有达到我的预期:

This is a long line of text (or at least, just pretend it is) so it
        will indent when it wraps.
        Further lines of text appear as normal, but again if they
        exceed the maximum width then they wrap and indent.

CSS中有没有办法缩进换行,但将换行算作新的第一行?

4

1 回答 1

1

不,因为text-indent与元素的第一行有关,并且换行生成的换行符不会创建元素。因此,您需要使用一些内容标记,而不仅仅是 HTML 源代码中的换行符。

于 2012-05-11T19:28:20.397 回答