//圣杯布局-wrap设置padding/left right加相对定位
<!DOCTYPE html> <html lang="zh-CN"> <html> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <title></title> <style> *{margin:0; padding:0;} .wrap{padding:0 200px; overflow: hidden} .main{100%; background:#57ccb1; float:left; height:100px;} .left{ float:left;margin-left:-100%; 200px; height:100px; background:#ff3f27; position:relative; left:-200px;} .right{ float:left;margin-left:-200px; 200px; height:100px; background:#fbb800; position:relative;right:-200px;} </style> </head> <body> <div class="wrap"> <div class="main">main</div> <div class="left">left</div> <div class="right">right</div> </div> </body> </html>
//双飞翼布局-在main中嵌套一层设置margin
<!DOCTYPE html> <html lang="zh-CN"> <html> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> <title></title> <style> *{margin:0; padding:0;} .main{100%; background:#57ccb1; float:left; height:100px;} .left{ float:left;margin-left:-100%;opacity:0.4; 200px; height:100px; background:#ff3f27; } .right{ float:left;margin-left:-200px;opacity:0.4; 200px; height:100px; background:#fbb800; } .main_con{margin-left:200px; margin-right:200px;} </style> </head> <body> <div class="wrap"> <div class="main"> <div class="main_con">main</div> </div> <div class="left">left</div> <div class="right">right</div> </div> </body> </html>