您的位置:首页 > 其它

圣杯布局(目的就是为了实现自适应分辨率)和等高布局(目的就是实现左右两边的高度等高,并且高度有内容撑开)

2014-10-13 15:11 246 查看
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>圣杯布局</title>
<style>
body{margin:0;}
.center{height:600px;background:#f60;margin:0 200px;}
.left{width:200px;background:#fc0;height:600px; position:absolute;left:0;top:0;}
.right{width:200px;background:#fcc;height:600px;position:absolute;right:0;top:0;}
</style>
</head>
<body>
<div class="center"></div>
<div class="left"></div>
<div class="right"></div>
</body>
</html>


圣杯布局(目的就是为了实现自适应分辨率)

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>等高布局(目的就是实现左右两边的高度等高,并且高度由内容撑开)</title>
<style>
body{margin:0;}
.wrap{ width:900px;margin:0 auto;overflow:hidden;}
.left{width:200px;background:Red;float:left;padding-bottom:10000px;margin-bottom:-10000px;}
.right{width:700px;background:blue;float:right;padding-bottom:10000px;margin-bottom:-10000px;}
</style>
</head>
<body>
<div class="wrap">
<div class="left">
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
</div>
<div class="right">
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
页面内容<br/>
</div>
</div>
</body>
</html>


等高布局(目的就是实现左右两边的高度等高,并且高度有内容撑开)

2、css三层嵌套(宽高自适应)

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
body{ background:#000;}
.btnL{width:100px;margin:0 auto;background:url(img3/btnL.gif) no-repeat;}
.btnR{ background:url(img3/btnR.gif) no-repeat right 0;}
.btn{height:25px;background:url(img3/btn.gif) repeat-x;margin:0 9px;}
</style>
</head>
<body>
<div class="btnL">
<div class="btnR">
<div class="btn"></div>
</div>
</div>
</body>
</html>


方式2
这2种方式,1是通过背景定位方式实现。2是通过margin实现。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐