当文本换行为HTML段落时,使用* only * css与第一行上的第一个非空白字符对齐


When text wraps in HTML paragraph, align to first non-whitespace character on first line with *only* css

我有一段文字如下:

1
2
3
4
5
6
7
<p>


&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp; In this respect, the conceptual structure of the Act is something like a pyramid. The pyramid shape illustrates the way the income tax law is organised, moving down from the central or core provisions at the top of the pyramid, to general rules of wide application and then to the more specialised topics.


</p>

目前它呈现出:

?????????????????? In this respect, the conceptual structure of the Act is something like a pyramid. The pyramid shape illustrates the way the income tax law is organised, moving down from the central or core provisions at the top of the pyramid, to general rules of wide application and then to the more specialised topics.

我希望它像这样呈现:

1
2
3
4
5
?????????????????? In this respect, the conceptual structure of the Act is something like a
?????????????????? pyramid. The pyramid shape illustrates the way the income tax law is  
?????????????????? organised, moving down from the central or core provisions at the top of
?????????????????? the pyramid, to general rules of wide application and then to the more
?????????????????? specialised topics.

只使用CSS!

背后的

我正在将降价文件转换为HTML。这些文件在源代码管理中。标记文件已经使用字符为我缩排。我还需要干净的提交日志,所以我希望将每个

保持在一行上。

编辑

以下是其中一个降价文档中一节的要点:https://gist.github.com/vjpr/5378401

基本上我想

  • 避免在我的降价文档中使用内联HTML。
  • 允许使用缩进在Github上查看降价文档。
  • 允许使用自定义样式表查看相同的降价文档,并保持段落的缩进级别与第一个非空白字符的缩进级别相同,如图所示。


您可以使用填充左文本缩进和负文本缩进的组合,例如

1
2
3
4
5
p{
    padding-left:18em;
    border: 1px solid black;
    text-indent :-9em;
}

示例:http://jsfiddle.net/nzutm/1

您可以根据需要调整填充和缩进。