圣杯布局(目的就是为了实现自适应分辨率)和等高布局(目的就是实现左右两边的高度等高,并且高度有内容撑开)
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实现。
相关文章推荐
- 轻松实现两栏布局:左右DIV等高、内容自适应屏幕高度
- 如何实现网页左右两边盒子高度自适应布局
- 自适应布局,完美解决左右两边固定大小,中间内容适应大小。
- 左右两列自适应中间列内容即随中间内容高度自适应的布局
- CSS实现左右栏宽度固定中间栏宽度变化且各栏高度自适应背景色不同的三栏布局
- 两列布局:左边固定宽度,右边自适应宽度,并且左边高度固定,右边自适应,两边的底边一直对齐
- 左定宽度右自适应宽度并且等高布局实现代码
- 奇怪的问题,关于js+css实现页面内容高度自适应的两种解决方案
- CSS布局:三栏布局,中间栏固定宽度,左右两边自适应
- 左右固定,中间自适应布局(方法5以后进阶,实现中间栏优先加载)
- CSS布局——左定宽度右自适应宽度并且等高布局
- css实现左栏固定右栏自适应,高度自适应的布局
- CSS等高布局,3div自适应最高的高度
- CSS布局——左定宽度右自适应宽度并且等高布局
- (div+css)上下固定中间自适应高度网页布局的实现(FF,IE)
- (div+css)上下固定中间自适应高度网页布局的实现
- jquery/js实现文本框根据输入内容input,textarea自适应高度
- 基于jQuery实现左右div自适应高度完全相同实现代码
- asp.net的多行文本框(TextBox)随内容增加而高度增加,并且不显示垂直滚动条的实现!
- 纯div+css实现列等高,左右div适应高度