【发布时间】:2020-03-05 12:08:29
【问题描述】:
我正在尝试获得一个自定义的有序列表来处理段落和其他容器,但我无法让列表的行为与默认值相同。
具体来说,我希望有一个自定义列表和分段内容,它与枚举出现在同一行。另外,我正在寻找一种可以更改列表而不是段落的解决方案。该段落只是一些我不想更改的生成内容的示例。
.custom {
list-style-type: none;
counter-reset: elementcounter;
}
.custom li:before {
content: counter(elementcounter) ". ";
counter-increment: elementcounter;
}
.solution {
list-style-type: none;
counter-reset: elementcounter;
}
.solution li>p {
display: inline-block;
}
.solution li:before {
content: counter(elementcounter) ". ";
counter-increment: elementcounter;
}
<ol>
<li><p>Places nicely on the same line.</p></li>
<li><p>Places nicely on the same line.</p> <p>Places nicely on the same line.</p></li>
</ol>
<!-- Original problem
<ol class="custom">
<li><p>Places poorly on the second line.</p></li>
<li><p>Places poorly on the second line.</p> <p>Places nicely on the second line.</p></li>
</ol>
-->
<ol class="solution">
<li><p>Places poorly on the second line.</p></li>
<li><p>Places poorly on the second line.</p> <p>Places poorly on the same line.</p></li>
</ol>
【问题讨论】:
-
display:inline-block到p? -
我已经尝试过了,但如果您有可行的解决方案,请提供代码片段。