我设计了一个网页来检索雅虎财经的股票信息,使用Javascript。现在我在格式化表格时遇到了问题,因为表格包含的列太多,无法在屏幕上显示。
我想要实现的是让用户滚动表格以查看超出预定义限制的列/行。
我尝试组合使用这些格式,但都没有用:
#stockDataTable {
max-width:600px;
table-layout: fixed;
overflow-x: scroll;
overflow-y: scroll;
}
你对表格的格式有什么建议吗?
我已经将html和css代码保存在jsfiddle.net中:http://jsfiddle.net/lcazarre/PCW6F/
谢谢,LC
发布于 2014-02-20 20:17:10
您不能阻止表的宽度增长,但您可以简单地插入到具有固定宽度的DIV中,并在DIV上使用overflow: scroll
。
发布于 2014-02-20 20:20:02
HTML:
<div id="wrap-table">
<table id="stockDataTable">
...
</table>
</div>
CSS:
#wrap-table {
overflow:scroll;
/* Add some padding so the scrollbar isn't overlapping the table */
padding-bottom:10px;
}
https://stackoverflow.com/questions/21918538
复制