实现的效果大致是这样的:左右两个div左边div的高度随着右边的高度发生变化,当两者的最大高度都不超过屏幕高度时整屏显示,当右边高度发生变化时候那么左边的高度跟随其发生变化:实现的关键点有两点:1 合理运用min-height 2 padding-bottom:9000px;margin-bottom:-9000px;两者的结合运用。下面贴上源码仅供参考;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
html,body{
height: 100%;
}
.main{
width: 100%;
min-height: 100%;
background-color: pink;
overflow: hidden;
}
.header{
float: left;
width: 100%;
height: 100px;
background-color: blue;
}
.left{
float: left;
width: 150px;
min-height: 100%;
background-color: green;
padding-bottom:9000px;
margin-bottom:-9000px;
}
.right{
float: left;
width: calc(100% - 150px);
min-height: 100%;
background-color: red;
padding-bottom:9000px;
margin-bottom:-9000px;
}
</style>
</head>
<body>
<div class="main">
<div class="header"></div>
<div class="left">
<ul>
<li>1</li>
</ul>
</div>
<div class="right">
<div class="txt">
<table>
<caption>table title and/or explanatory text</caption>
<thead>
<tr>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
</tr>
</tbody>
</table>
<table>
<caption>table title and/or explanatory text</caption>
<thead>
<tr>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>