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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:40:39  来源:igfitidea点击:

Add scrollbar to table

htmlcss

提问by Shruti

I want to add a vertical and horizontal scroll bar to the table with fixed header. By using theadand tbodytags I could add scrollbar in firefox but IE does not support the overflow:auto propertyin tbody. IE8 does not support css expressions so can you tell me how to accomplish this?

我想在带有固定标题的表格中添加一个垂直和水平滚动条。通过使用theadtbody标签,我可以在 firefox 中添加滚动条,但 IE 不支持overflow:auto propertyin 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 trwhich 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 pxof the tbody.

使用overflow:scroll. 您可能还必须pxtbody.

回答by Bryce Roney

If you have overflowset to autothe tbody will just show the overflow, you need to explicitly state overflow: scrolland have a fixed height for the <tbody>.

如果您已overflow设置为autotbody 将只显示溢出,则您需要明确声明overflow: scroll并为<tbody>.