DIV+CSS,上下2个div,上面固定宽度100px,下面的如何自动延伸到浏览器低端?(如下例,黄块怎么自动延伸)
<divstyle="height:100px;background:green;width:80%;"></div><divstyle="height:50%;back...
<div style="height:100px;background:green;width:80%;"></div>
<div style="height:50%;background:yellow;"></div> 展开
<div style="height:50%;background:yellow;"></div> 展开
1个回答
展开全部
方案一
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
html,body{height: 100%;margin:0;padding:0;}
.box{height: 100%;padding-top: 100px;box-sizing: border-box;position: relative;}
.green{position: absolute;top:0;left:0;}
.yellow{height: 100%;}
</style>
<script src="jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="box">
<div class="green" style="height:100px;background:green;width:80%;"></div>
<div class="yellow" style="background:yellow;"></div>
</div>
</body>
</html>
方案二
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
html,body{margin:0;padding:0;}
.box{height: 100vh;}
.green{height:100px;}
.yellow{height: calc(100vh - 100px);}
</style>
<script src="jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="box">
<div class="green" style="background:green;width:80%;"></div>
<div class="yellow" style="background:yellow;"></div>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询