简体   繁体   English

有没有一种纯CSS的方法来突出显示悬停时的html表列?

[英]Is there a pure-CSS way to highlight a html table column on hover?

Is there a pure-CSS way to highlight a html table column on hover? 有没有一种纯CSS的方法来突出显示悬停时的html表列?

So when you hover over on <td> , all of the other <td> of that same child position would take on the same style? 所以,当你将鼠标悬停在<td>其他所有的<td>是同一个孩子的位置将采取相同的风格?

I looked at <col> tag, but didn't seem to do what I expected. 我查看了<col>标签,但似乎没有达到我的预期。

Looks like what you want is done by CSS Tricks 看起来您想要的是CSS技巧完成的

Basically you just set a crazy high height on the TDs on hover and then give a background. 基本上,您只是在悬停的TD上设置了疯狂的高度,然后提供背景。 Seems to be a pretty interesting thought to do this. 似乎很有趣。 They love their hacks. 他们喜欢自己的技巧。 The table{ overflow: hidden; } table{ overflow: hidden; } table{ overflow: hidden; } is super key here. table{ overflow: hidden; }是此处的超级键。

WORTH NOTING.... Can't do nested with this approach. 值得一提...。这种方法无法嵌套。

The negative z-index keeps it below the content. 负的z-index使其保持在内容之下。 Negative z-index is a fun trick, but beware this table then can't be nested within other elements with backgrounds, otherwise the highlight will go below them. 负z索引是一个有趣的技巧,但是请注意,此表不能嵌套在其他有背景的元素中,否则突出显示将在它们的下面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM