PTT
Submit
Submit
选择语言
正體中文
简体中文
PTT
Web_Design
[问题] Child combinator >
楼主:
kisha024
(4545454554)
2023-07-04 13:38:51
各位好
https://jsfiddle.net/rxd8eyw1/
如上连结
table > tr {
color: red;
}
<table>
<tr>
<th></th>
<th scope="col">国文</th>
<th scope="col">英文</th>
<th scope="col">数学</th>
</tr>
<tr>
<th scope="row">张三</th>
<td>78</td>
<td>60</td>
<td>98</td>
</tr>
<tr>
<th scope="row">李四</th>
<td>67</td>
<td>65</td>
<td>85</td>
</tr>
<tr>
<th scope="row">王五</th>
<td>69</td>
<td>85</td>
<td>45</td>
</tr>
</table>
https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator
在HTML的结构上 tr 应该是 table 的 direct child 吧
但 table > tr 这样写,好像没 match 到 tr
我知道可以用 table tr, 但为什么 table > tr 不行呢?
谢谢
作者: nick8195 (煎饼)
2023-07-04 13:46:00
虽然html当中没有使用,但结构上table底下还有tbody改成table>tbody>tr就能达到效果了
作者:
qptw
(老鱼儿)
2023-07-04 15:02:00
>是子代,也就是TABLE里面第一子层必须是TR,而空格则是后代的概念,TABLE 里面可以隔着别人,只要找到TR就可以了
作者:
microloft
(微阁)
2023-07-04 15:28:00
承1楼,就算你没写tbody,浏览器还是会自动帮你加
作者:
nottt
(无)
2023-07-04 16:32:00
https://i.imgur.com/gyjgenB.png
不要相信自己的原始码以浏览器渲染出来的为主,因为可能被js或其他外挂更换html
继续阅读
[请益] 急件_征求前端工程师除bug
wow4momo
Re: [请益] 网页技术是如何实现动态生成大量的html
WalkingIce
[问题] npm install 错误
KaiLoveMoon
[问题] 合适中学生的网页设计书
krf08
[请益] 网页技术是如何实现动态生成大量的html
xxzrainy
Re: [心得] 运用AI下媒体广告、创造Google搜寻排行
angus7684
[心得] 运用AI下媒体广告、创造Google搜寻排行
angus7684
[请益] 征合作伙伴 已征到
iceann
[请益] 想做横向卷动网页但卷动区块莫名其妙太长
hoyunxian
Re: [问题] 国外虚拟主机的介绍奖金都很高吗?
hoonhee1004
Links
booklink
Contact Us: admin [ a t ] ucptt.com