gpt4 book ai didi

CSS nth-child,穿越 Twig

转载 作者:行者123 更新时间:2023-11-28 10:48:42 33 4
gpt4 key购买 nike

我有一个包含类别标题的列表,以及嵌套在这些标题中的元素。如果我这样做

#list .item:nth-child(1):before{content:"1";}

每个类别中的第一项都以 1 为前缀。这有点出乎意料。我想我正在寻找一个 nth-item() 插件。

如果我不控制 html,我有什么选择,它是动态变化的,我不想用 jQuery 监视它。我希望有一个 CSS 解决方案。

Link to Fiddle

最佳答案

您也可以使用 CSS counter

http://jsfiddle.net/6tN5U/

body {
counter-reset: item;
}

.item{
margin-left:20px;
}
#items .item:before{counter-increment: item; content: counter(item) " ";}

关于CSS nth-child,穿越 Twig ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24197567/

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