gpt4 book ai didi

CSS nest-list - 如何分段

转载 作者:太空宇宙 更新时间:2023-11-04 08:45:02 25 4
gpt4 key购买 nike

我正在创建一个像这样的列表 enter image description here

我想把罗威纳犬和杜宾犬列为 1.1 和 1.2,但我不知道该怎么做。我复制了那个 css 列表模板并做了一些修改。这是代码:

#lista2 {
counter-reset: li;
list-style: none;
*list-style: decimal;
font: 15px 'trebuchet MS', 'lucida sans';
padding: 0;
margin-bottom: 4em;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

#lista2 ol {
margin: 0 0 0 2em;
counter-reset: section;
list-style-type: none;
}

#lista2 li{
position: relative;
display: block;
padding: .4em .4em .4em 2em;
*padding: .4em;
margin: .5em 0;
background: #ddd;
color: #444;
text-decoration: none;
border-radius: .3em;
transition: all .3s ease-out;

}

#lista2 li:hover{
background: #eee;
}

#lista2 li:hover:before{
transform: rotate(360deg);
}

#lista2 li:before{
content: counter(li);
counter-increment: li;
position: absolute;
left: -1.3em;
top: 50%;
margin-top: -1.3em;
background: #87ceeb;
height: 2em;
width: 2em;
line-height: 2em;
border: .3em solid #fff;
text-align: center;
font-weight: bold;
border-radius: 2em;
transition: all .3s ease-out;
}

#lista2 ol ol li:before{
counter-increment: li;
content: counters(li,".") " ";
}
#lista2 ol {
counter-reset: li;
list-style: none;
}
<ol id="lista2">
<li>Animals
<ol>
<li>Dogs</li>
<ol>
<li>Rottweiler</li>
<li>Doberman</li>
</ol>
<li>Cats</li>
<li>Cacatoos</li>
</ol>
</li>
</ol>
我希望有人能帮助我。谢谢!

最佳答案

Plunkr 链接 - https://plnkr.co/edit/dtn5xgoOOoSmVc4B3LrH?p=preview

HTML:

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<style>
OL { counter-reset: item }
LI { display: block }
LI:before { content: counters(item, ".") " "; counter-increment: item }
</style>
</head>

<body>
<ol>
<li>Dogs

<ol>
<li>Rottweiler</li>
<li>Doberman</li>

</ol>
</li>
<li>Cats
</li>
<li>Cacatoos</li>
</ol>

</body>

</html>

CSS:

OL { counter-reset: item }
LI { display: block }
LI:before { content: counters(item, ".") " "; counter-increment: item }

关于CSS nest-list - 如何分段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43835289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com