Floating horizontal scroll bar for html table

时间秒杀一切 提交于 2019-12-20 02:22:25

问题


I have an html table that is very tall. The web page has to be scrolled vertically to reach the scroll bar at the bottom of the table. It would be nice if I could float the horizontal scroll bar for the table at the bottom of the browser window while the user is scrolling the page and the table is visible. Can such a thing be done?

Here is a jsFiddle example of the situation: http://jsfiddle.net/RurTZ/1/


回答1:


The Grid suggestion by @KDavid is good, but if you're looking for something a bit lighter I had success with the the floatingScrollbar jQuery plugin (demo).

After making sure the plugin JS is loaded, the magic call happens:

$('.your-div').floatingScrollbar();

I also had to set the div CSS to:

.your-div {
  overflow-x: auto;
  width: 100%;
}

Here is a fork of your jsFiddle with it working: http://jsfiddle.net/RxTQM/1/




回答2:


Yes, place it inside a <div> tag, and add overflow:scroll; to the style of the div.



来源:https://stackoverflow.com/questions/12075757/floating-horizontal-scroll-bar-for-html-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!