简体   繁体   English

表格 header 在顶部滚动后浮动的时尚风格

[英]Stylish style to float the table header after it's been scrolled on top

I'm trying to write myself a little Stylish style for one page, for easier reading.我正在尝试为一页写一点时尚风格,以便于阅读。
The page in question is https://satisfactory.fandom.com/wiki/Hard_Drive .有问题的页面是https://satisfactory.fandom.com/wiki/Hard_Drive
What I want to achieve is to the top row of this table (with "alternate name", "product" and so on)我想要实现的是该表的第一行(带有“备用名称”、“产品”等) 在此处输入图像描述 to behave similar to the top wikia navbar - I want it to be on it's place, until it's been scrolled past down, then to stay at the top - sort of as freezing a row in a spreadsheet.表现类似于顶部的 wikia 导航栏 - 我希望它在它的位置,直到它向下滚动,然后留在顶部 - 有点像冻结电子表格中的一行。

The position: sticky; position: sticky; should do what I want, but nothing changes.应该做我想做的,但没有任何改变。 I've tried with background-color to see if I'm targeting the proper element, and the background color changed.我已经尝试使用background-color来查看我是否针对正确的元素,并且背景颜色发生了变化。

Here's how I'm trying to do it这是我正在尝试的方式

table#alternateRecipesTable th {
    position:sticky!important;
    top: 0px!important;
}

I'm using firefox 100 with stylus 1.5.21.我正在使用 firefox 100 和手写笔 1.5.21。

Thank you.谢谢你。

Your plan to set the position: sticky CSS property is correct.您计划设置position: sticky CSS 属性是正确的。 However, to work this as expected, there can't be a parent element with overflow: hidden .但是,要按预期工作,父元素不能有overflow: hidden

If you set the position: sticky to your head cells of the table, you also need to check every parent element and unset the overflow: hidden property, otherwise it will not work.如果将position: sticky设置到表格的 head 单元格,则还需要检查每个父元素并取消设置overflow: hidden属性,否则它将不起作用。

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

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