<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>div两栏等高布局</title>
<style type="text/css">
*{
padding: 0;margin: 0;text-align: center;
}
.header,.footer{
padding: 10px 0;width: 100%;background: #eee;font-size: 20px;
}
.wrap{
width: 100%;
margin: 0 auto;
overflow: hidden;
display: inline-block;
}
.wrap:after{
display: block;
content:'[DO NOT LEAVE IT IS NOT REAL]';
height: 0;clear:both;
visibility: hidden;
}
.left{
width: 30%;float: left;background: #fff;text-align: left;
}
.right{
width: 70%;float: left;background: #0278b5;
}
.left,.right{
padding-bottom: 32767px !important;
margin-bottom: -32767px !important;
}
@media all and(min-width:0px){
.left,.right{
margin-bottom: 0px !important;
padding-bottom: 0px !important;
}
.left:before,.right:before{
content:'[DO NOT LEAVE IT IS NOT REAL]';
display: block;
background: inherit;
padding-top: 32767px !important;
margin-bottom: -32767px !important;
height:0;
}
}
.footer{
float: left;
}
</style>
</head>
<body>
<div class="wrap">
<div class="header">
<h1>header</h1>
</div>
<div class="left">
<h2>sideleft</h2>
左上
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
左下
</div>
<div class="right">
<h2>sideright</h2>
右上
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
右下
</div>
</div>
<div class="footer">
<h1>footer</h1>
</div>
</body>
</html>
注释:
content 属性与 :before 及 :after 伪元素配合使用,来插入生成内容。
例如a:after{content:‘[DO NOT LEAVE IT IS NOT REAL]'}则会在链接后面加上[DO NOT LEAVE IT IS NOT REAL]文本;
32767应该是动态脚本生成,为16位有符号整数最大值,没有太大意义
机器字长为16位,则无符号数的表示范围是0-65535,有符号位的表示范围:-32767-32767(此数值对应原码表)
1000-0 (15个0)这个数因为是补码表示,所以
它不是0,而是:-2的15次方=-32768.
这个是最小的;
最大到:
0111-1 (15个1) =2的15次方-1
=32767
第二种
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/details.css">
<!-- // <script type="text/javascript" src="js/index.js"></script> -->
<style type="text/css">
/* .container {width:960px; height:100%; overflow:hidden; margin:0 auto;}
.left {height:100%; width:200px; overflow:hidden; padding-bottom:9999px; margin-bottom:-9999px; float:left; display:inline;}
.right {width:750px; float:right; height:auto;}*/
#content{overflow:hidden;}
.left{width:200px; margin-bottom:-3000px; padding-bottom:3000px; background:#cad5eb; float:left;}
.right{width:400px; margin-bottom:-3000px; padding-bottom:3000px; background:#f0f3f9; float:right;}
/*.center{margin:0 410px 0 210px; background:#ffe6b8; height:600px;}*/
</style>
</head>
<body>
<!-- <div class="container">
<div class="left" style="background:red"></div>
<div class="right" style="background:pink"></div>
</div> -->
<div id="content">
<div class="left">左边,无高度属性,自适应于最高一栏的高度
</div>
<div class="right">右边,无高度属性,自适应于最高一栏的高度
<br>
<br>
<br>
<br>
<br>
</div>
<div class="center">中间,高度600像素,左右两栏的高度与之自适应</div>
</div>
</body>
</html>