HTML - 在表格的单元格内启用滚动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3537734/
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 04:12:51  来源:igfitidea点击:

HTML - Enable Scrolling within a Table's Cell

htmlscrollhtml-tablecell

提问by Moon

Let's say I have a table cell with fixed width and height.... and I have data that exceeds the cell's fixed dimensions...

假设我有一个固定宽度和高度的表格单元格......并且我的数据超过了单元格的固定尺寸......

<td width="500" height="300">lots of data that exceeds the dimensions</td>
  • can I enable scrolling of this data within a cell....
  • if not than what is the solution.. I only have that 500 x 300space
  • 我可以在单元格内启用这些数据的滚动吗....
  • 如果不是,那么解决方案是什么..我只有500 x 300 的空间

回答by Pekka

The easiest thing would be to add a 500 x 300 div and give it overflow: auto

最简单的方法是添加一个 500 x 300 div 并给它 overflow: auto

<td width="500" height="300">
 <div style="width: 500px; height: 300px; overflow: auto">
  lots of data that exceeds the dimensions
 </div>
</td>