I have a really large datatable and I want to put the horizontal scrollbar on top as well as on the bottom of the table so it would be easier for the user to scroll (the datatable has a lot of columns). Is there an easy and proper way to achieve this?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
pls have a look at a similar query here:
horizontal scrollbar on top and bottom of table
This solution has worked for my datatable.
You can use overflow property in css.
You should separate body and header of your table in two different tables. then place the second table (body of original table) in a div and use overflow on this div.
DEMO in jsfiddle
I show scrollbar of the header with css/jQuery and set the body scrollLeft to the header's scroll left.
Example:
You can use a container that has a maximum width and put the table inside.
Depending on how much reliability you want, you can make:
A. Bottom scrollbar, just set a maximum width and overflow x to scroll:
Demo:
B. Top scrollbar, a little hacky, use a 180 degree transform to rotate the scrollbar to the top, then again another 180 degree to put back the content.
You may want to use broswser specific prefixes for transform, like
-webkit-transform:rotateX(180deg);
.Demo:
C. Top and bottom scrollbar, a little more hacky. Needs some javascript. Use the solution form A above and add a 'fake' div for top scrollbar:
And a little javascript to catch the scroll on the top fake div and then scroll the table container (and vice-versa), with jQuery:
Demo:
The working complete code for all three solutions:
I found the solution to put scroll on top of table. Have look please: Demo in Fiddle Hope it would help.