【发布时间】:2012-05-11 19:04:34
【问题描述】:
我已经有了以下样式: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 中缩进换行,但将换行算作新的第一行?
【问题讨论】:
-
如果换行符表示为单独的元素,对我来说效果很好。 jsfiddle.net/gNVgQ
-
@jessegavin 但他们不是,这就是
white-space: pre-wrap的全部意义所在。 -
你能把每一行都换成
<div>吗?然后你可以使用text-indent和padding-left。
标签: css text-indent