编辑:添加:http://jsfiddle.net/bfNzH/1/
我的HTML的结构如下:
<body>
<div class="wrapper">
<div class="left">left bar</div>
<div class="right">
<div class="topbar">topbar</div>
<div class="header">header</div>
<div class="content">
<div>..some stuff</div>
<table>
<thead>
<tr>
<th class="th1">Col1</th>
<th>Col2</th>
<th>Col3</th>
<th>Col4</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</body>
的CSS
body {
height : 100%;
}
.wrapper {
position : absolute;
top : 0;
bottom : 0;
left : 0;
right : 0;
overflow : hidden;
}
.left {
height : 100%;
position : absolute;
width : 50px;
overflow : hidden;
border-right : 1px solid black;
}
.right {
position : absolute;
top : 0;
left : 50px;
bottom : 0;
right : 0;
//border : 1px solid red;
}
.topbar {
height : 20px;
display : table;
width : 100%;
border-bottom : 1px solid green;
}
.header {
height : 30px;
display : table;
width : 100%;
}
.content {
width : 100%;
height : 100%;
position : absolute;
overflow : auto;
top : 50px;
bottom : 0px;
border-top : 1px solid yellow;
border-bottom : 1px solid yellow;
}
.th1 {
width : 50%;
}
table {
width : 100%;
}
th, tr {
text-align : center;
}
如果我的表中有很多行,则内容超出页面范围,并出现滚动条..但这就是滚动条发生的情况:
我了解了这一点,因为我已经绝对定位了元素并添加了一个元素,top
因此垂直滚动条已移动了该数量。
我想要2个解决方案之一:
我可以通过添加来实现第二个display : block
,tbody
但随后会严重破坏对齐方式。观察:
如果height: 100%;
从内容块中删除,滚动条将显示其实际高度:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句