纯css怎么控制一个div的高度跟随另外一个DIV高度发生变化

实现的效果大致是这样的:左右两个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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值