简体   繁体   中英

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 .
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.

The 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.

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.

Thank you.

Your plan to set the position: sticky CSS property is correct. However, to work this as expected, there can't be a parent element with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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