gpt4 book ai didi

css - 我在这里错过了什么吗? first-child 不能用在按钮上吗?

转载 作者:行者123 更新时间:2023-11-28 11:17:19 27 4
gpt4 key购买 nike

我正在尝试使用以下标记将第一个子类应用到按钮上:

button:first-child {
background: red;
}

但它会将我所有的按钮都变成红色,而不仅仅是第一个。 html 标记是这样的:

    <ul>
<li>
<button type="button"><img src="larrow.png" alt="<" /></button>
</li>
<li>
<button type="button">Test</button>
</li>
<li>
<button type="button"><img src="rarrow.png" alt=">" /></button>
</li>
</ul>

有什么建议吗?我确定我只是做错了什么。

最佳答案

试试 ul li:first-child button {background: red}

演示: http://jsbin.com/uzoko4

关于css - 我在这里错过了什么吗? first-child 不能用在按钮上吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4914303/

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