Html 将滚动条添加到表格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1320914/
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
Add scrollbar to table
提问by Shruti
I want to add a vertical and horizontal scroll bar to the table with fixed header. By using thead
and tbody
tags I could add scrollbar in firefox but IE does not support the overflow:auto property
in tbody
. IE8 does not support css expressions so can you tell me how to accomplish this?
我想在带有固定标题的表格中添加一个垂直和水平滚动条。通过使用thead
和tbody
标签,我可以在 firefox 中添加滚动条,但 IE 不支持overflow:auto property
in tbody
. IE8 不支持 css 表达式,所以你能告诉我如何做到这一点吗?
回答by Abhijit Gaikwad
with CSS it should be easy
使用 CSS 应该很容易
div.scrollWrapper{
height:250px;
width:200px;
overflow:scroll;
}
<div class="scrollWrapper">
<table >
<tbody height="xxx">
<tr>......
</tbody>
</table>
</div>
回答by Shruti
On giving fixed height also that is not working in IE. The height is getting applied to tr
which I gave to tbody
.
在给出固定高度时,这在 IE 中也不起作用。高度正在应用tr
我给tbody
.
回答by vijay
Use CSS for the task required:
将 CSS 用于所需的任务:
#tableID { overflow: scroll; }
HTML:
HTML:
<table id="tableID">
...
</table>
About coloring visit this link http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/scrollbarColor.htm
关于着色访问此链接http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/scrollbarColor.htm
回答by awe
Try your original solution using overflow:scroll
. You might also have to set a fixed height in px
of the tbody
.
使用overflow:scroll
. 您可能还必须px
在tbody
.
回答by Bryce Roney
If you have overflow
set to auto
the tbody will just show the overflow, you need to explicitly state overflow: scroll
and have a fixed height for the <tbody>
.
如果您已overflow
设置为auto
tbody 将只显示溢出,则您需要明确声明overflow: scroll
并为<tbody>
.