要快速了解我所遇到的问题,请首先快速浏览下面的比较图片,其中显示了我想要实现的压痕效果与实际获得的压痕效果。
我正在尝试使每个小节中的所有行排成一行,以其文本内容的第一个字符为准,缩进超过节符号所占用的空间。
我相信这类似于悬挂缩进,除了它更聪明是因为它知道每个节符号的字符串长度并进行相应调整。我不确定这种效果的确切名称是什么(如果有的话)。
我已经尝试使用text-indent
和其他属性,但没有成功。文本是带有子项目的有序列表。
当枚举为1.1.2
或1.1
时,如上所述无法实现文本缩进/对齐。
ol {
counter-reset: item;
}
li {
display: block;
}
li:before {
content: counters(item, ".") " ";
counter-increment: item;
}
<div class ="all-text">
<div align="center" ><b>TITLE</b></div>
<br><br>
<div class ="lista-principal"> <!-- div da lista ordenada principal -->
<ol> <!-- Lista ordenada principal -->
<!-- Inicio do ITEM 1 da lista principal P1 -->
<li> <span>TITULO</span>
<ol>
<li>
But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"
</li>
</ol>
</li>
<!-- Fim do ITEM 1 da lista principal P1 -->
<!-- Inicio do ITEM 2 da lista principal P1 -->
<li>
<span>OBJETO</span>
<ol>
<li>
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
</li>
<li>
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
</li>
<li>
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
</li>
</ol>
</li>
<!-- Fim do ITEM 2 da lista principal P1 -->
</ol> <!-- FIM da lista ordenada principal -->
答案 0 :(得分:1)
此代码对我有用:
css
preProcess
HTML:
ol {
counter-reset: item;
}
li {
display: block;
position: relative;
padding-left: 15px;
}
ol ol li{
padding-left: 30px;
}
li:before {
content: counters(item, ".") " ";
counter-increment: item;
position: absolute;
left: 0;
top: 0;
}