本文介绍了有序列表CSS样式包括父编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在寻找使用CSS创建如下所示的有序列表:
We're looking to use CSS to create an ordered list that looks like this:
A.
A.1
A.2
B.
C.
C.1
C.2
C.2.1
C.2.2
您如何像这样将父级索引包含在子级中?
How would you include the parent index in the child like this?
推荐答案
您应使用 CSS计数器 (为 @Zeta )指出,但这是一种可处理多个嵌套和拉丁计数器的方法.
You should use CSS counters (as @Zeta) has pointed out, but here is an approach that will handle multiple nesting and latin counters ..
ol{
list-style: none;
}
ol.roman{
counter-reset: roman;
}
ol.roman > li:before{
counter-increment: roman;
content: counter(roman, upper-latin)".";
padding-right:5px;
}
ol.roman li ol{
counter-reset: inner;
}
ol.roman ol li:before{
counter-increment: inner;
content: counter(roman, upper-latin)"."counters(inner,'.');
padding-right:5px;
}
演示在 http://jsfiddle.net/gaby/nZQSF/
这篇关于有序列表CSS样式包括父编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!