gpt4 book ai didi

css:如何在表格中选择第一个 anchor 标记

转载 作者:太空宇宙 更新时间:2023-11-03 21:44:52 25 4
gpt4 key购买 nike

 <table id="table">
<tr>
<th><a href="main.html">edit</a><th>
<th><a href="main2.html">update</th>
<th>........</th>
</tr>
<tr>
blah blah
</tr>
</table>

这里我想选择第一个 anchor 元素来添加一些样式

我试过了

table#table a:first-child{
color: #888888;
font-weight: normal;
text-align: left;
}

但是失败了

最佳答案

你是说这样吗?

HTML:

<table id="table">
<tr>
<th><a href="main.html">edit</a>
</th>
<th><a href="main2.html">update</a>
</th>
<th>........</th>
</tr>
<tr>
<th><a href="main.html">edit</a>
</th>
<th><a href="main2.html">update</a>
</th>
<th>........</th>
</tr>
</table>

CSS:

#table th:first-child a {
color: red;
font-weight: normal;
text-align: left;
}

您想选择第一个 <th>然后找到<a> .

DEMO HERE

关于css:如何在表格中选择第一个 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21134308/

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