css - 滚动不适用于动态表

标签 css

我有一个带有 class=list 的表,它输出上传到服务器的文件,它是使用 php 动态创建的。该表在另一个 div 中。代码是

<div class="list">
<table>....php code for table...</table>
</div>

我已经把div列表定位到固定位置了,css文件是

.list{background:#66CDAA;width:20cm;position:fixed;top:3cm;left:11cm;}

问题是如果表格变得太大,页面不会向下滚动。我试过:

body{overflow:auto}

但它不起作用。 作为替代解决方案,我知道我可以添加到 .list

.list{overflow:auto;height:something;}

但是列表会有一个我不想要的固定高度,而且表格会滚动而不是页面。 那还有什么办法吗??

最佳答案

试试这个:

<div class="listcontainer"><div class="list"><table>...</table></div></div>

CSS:

.listcontainer {
    position: fixed;
    width: 20em;
    top: 3cm;
    left: 11cm;
    bottom: 3cm;
    right: 11cm;
    overflow: auto;
} /* adjust right and bottom to be what the maximum size should be */
.list {
    background-color: #66cdaa;
    max-height: 100%;
}

关于css - 滚动不适用于动态表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11385597/

相关文章:

html - 悬停时链接的多种字体颜色?

html - 在这种情况下,exactllly line-height 是如何工作的

javascript - Chrome 的表格布局 : fixed not working properly after changing the width of the table

php - CSS 文件链接在 PHP 页面上不起作用

html - 如何正确地将无序列表嵌入有序列表 (HTML)

php - CodeIgniter PHP 和模板库中的 Style.css

html - Bootstrap 模式中的图像问题

javascript - 滚动表格的一部分

html - Safari 边界半径溢出问题

JavaScript 禁用外部 CSS 的效果?