【发布时间】:2012-01-04 22:55:22
【问题描述】:
我正在尝试使用 CSS 解决方案来滚动表格内容,同时保持标题不变。
CSS 代码 1:
<style type='text/css'>
* {
padding:0;
margin:0;
border:0;
}
#ListData {
display:block;
width:100%;
height:100%;
float:left;
background:#ffffff;
}
#ListData table {
width:100%;
}
#ListData thead {
position:relative;
width:100%;
height:20px;
overflow:auto;
background:#0099cc;
}
#ListData tbody {
position:relative;
width:100%;
height:300px;
overflow:auto;
}
</style>
这种风格的输出在这里: http://riotdesign.in/test.php
这在 Firefox 中运行良好(我现在不关心 IE..)
但是,如果我使用百分比而不是 px 或 em:
<style type='text/css'>
* {
padding:0;
margin:0;
border:0;
}
#ListData {
display:block;
width:100%;
height:100%;
float:left;
background:#ffffff;
}
#ListData table {
width:100%;
}
#ListData thead {
position:relative;
width:100%;
height:10%;
overflow:auto;
background:#0099cc;
}
#ListData tbody {
position:relative;
width:100%;
height:50%;
overflow:auto;
}
</style>
这就是我得到的: http://riotdesign.in/test2.php
我做错了什么? :)
【问题讨论】: