CSS 如何使 DIV 的水平滚动条始终固定在页面底部?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11330745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I make the horizontal scrollbar for a DIV always appear fixed on the bottom of the page?
提问by Andreas Larsson
I have a website which contains a large (and wide) table. The table is placed inside jquery UI tabs.
我有一个包含大(宽)表的网站。该表位于 jquery UI 选项卡内。
It looks something like this: http://jsfiddle.net/Tq3Rg/
它看起来像这样:http: //jsfiddle.net/Tq3Rg/
For the user this can be somewhat annoying since he has to go all the way to the bottom of the table and page to scroll right.
对于用户来说,这可能有点烦人,因为他必须一直走到表格和页面的底部才能向右滚动。
Is it possible to make the scrollbar always appear fixedon the bottom of the page?
是否可以使滚动条始终固定在页面底部?
回答by Christoph
Set a fixed height (and don't use inline-styles):
设置固定高度(不要使用内联样式):
the code:
编码:
.top{
height:10%;
}
.center{
overflow:scroll;
height:80%;
}
.bottom{
height:10%;
}
If you really want to have the scrollbars at the very bottom of your page, you could check this answeron how to achieve this without needing custom scrollbars and such stuff.
如果您真的想在页面的最底部放置滚动条,您可以查看这个答案,了解如何在不需要自定义滚动条之类的情况下实现这一点。
回答by Andreas Larsson
Just set some fixed height to your middle div like
只需为您的中间 div 设置一些固定高度即可
<div style="background:white;overflow-y:scroll;height:400px;">
回答by Ashwin Singh
You need a custom scrollbar to do this, have a look http://baijs.nl/tinyscrollbar/or http://www.jquery4u.com/plugins/10-jquery-custom-scrollbar-plugins/#.T_RSYxEe4hU.
您需要一个自定义滚动条来执行此操作,请查看http://baijs.nl/tinyscrollbar/或http://www.jquery4u.com/plugins/10-jquery-custom-scrollbar-plugins/#.T_RSYxEe4hU。