gpt4 book ai didi

html - 第 n 个 child ()还是第一个 child ?如何选择第一个和第二个 child

转载 作者:技术小花猫 更新时间:2023-10-29 11:46:34 27 4
gpt4 key购买 nike

我想选择无序列表中的前两个列表项。我可以这样选择第一项:

ul li:nth-child(1) a {
background: none repeat scroll 0 0 beige;
}

ul li:first-child a {
background: none repeat scroll 0 0 beige;
}

我想同时选择第一个和第二个订单项 - 我该怎么做?

最佳答案

要选择第一个和第二个 child ,您可以使用单个 :nth-child() 伪类,如下所示:

ul li:nth-child(-n+2) a {
background: none repeat scroll 0 0 beige;
}

关于html - 第 n 个 child ()还是第一个 child ?如何选择第一个和第二个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8821193/

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