简体   繁体   中英

To set table headers fixed while scrolling

In explorer I am able to keep the thead part of my table fixed while scrolling using css expressions. Below is the css code snippet that does it : .standardTable thead tr { position: relative; top: expression(offsetParent.scrollTop); }

But this same doesn't work in chrome as expressions are deprecated for chrome. I need help in changing the "top" property of the above class using javascript or jquery. How to do it ?

Can it be done?

Sticky headers on tables are a very complex problem. WebKit has included a new CSS property position:sticky but it is only supported by less than 6 % of all user.

You can make a sticky header with jquery. Basically you just change the position of the header to fix if the user scrolls down. But because of many differed implementation of the table it is a mess. If you want to design it from scratch, here is a good tutorial. Otherwise you find a lot of good jQuery plugins online .

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