雙飛翼佈局:css
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>聖盃佈局</title> <style type="text/css"> *{margin: 0;padding: 0;} body{min-width: 700px;} .header, .footer{ border: 1px solid #333; background: #aaa; text-align: center; } .middle, .left, .right{ float: left; min-height: 200px; position: relative; } .container{ } .left{ margin-left: -100%; //是向左移動container的content的寬度個px width:200px; background-color: gray; } .right{ margin-left: -200px; //向左移動200px width: 200px; background-color: gray; } .middle{ background-color: blue; width: 100%; } .middle-inner{ margin:0 200px; //縮小middle的content的寬度,從而不被left和right覆蓋 } .footer{ clear: both; } </style> </head> <body> <div class="header"> <h4>header</h4> </div> <div class="container"> <div class="middle"> <div class="middle-inner"> <p>HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh </p> </div> </div> <div class="left"> <p>oooooooooooooo 00000000000000000 ooooooooooooooo ooooooooooooooo 000000000000000</p> </div> <div class="right"> <p>BBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBB 88888888888888888888</p> </div> </div> <div class="footer"> <h4>footer</h4> </div> </body> </html>
HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhtml
oooooooooooooo 00000000000000000 ooooooooooooooo ooooooooooooooo 000000000000000chrome
BBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBB 88888888888888888888佈局
聖盃佈局flex
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>聖盃佈局</title> <style type="text/css"> *{margin: 0;padding: 0;} body{min-width: 700px;} .header, .footer{ border: 1px solid #333; background: #aaa; text-align: center; } .middle, .left, .right{ float: left; min-height: 200px; position: relative; } .container{ padding: 0 200px; } .left{ margin-left: -100%; //將left與middle左邊對齊 left: -200px; //在將left向左移動200px,填充padding-left留下的空白 width:200px; background-color: gray; } .right{ margin-left: -200px; //將right和middle的右邊對齊 left: 200px; //在將right向右移動200px;填充padding-right留下的空白 width: 200px; background-color: gray; } .middle{ background-color: blue; width: 100%; } .middle-inner{ /*margin:0 200px;*/ } .footer{ clear: both; } </style> </head> <body> <div class="header"> <h4>header</h4> </div> <div class="container"> <div class="middle"> <div class="middle-inner"> <p>HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh HHHHHHHHHHHHHHHHHHHHHH hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh </p> </div> </div> <div class="left"> <p>oooooooooooooo 00000000000000000 ooooooooooooooo ooooooooooooooo 000000000000000</p> </div> <div class="right"> <p>BBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBB 88888888888888888888</p> </div> </div> <div class="footer"> <h4>footer</h4> </div> </body> </html>
效果和雙飛翼同樣,其實還能夠用flex彈性佈局,也能夠達到一樣的效果ui