3 回答

TA貢獻(xiàn)3593條經(jīng)驗 獲得超1個贊

TA貢獻(xiàn)14條經(jīng)驗 獲得超3個贊
左右DIV都自適應(yīng)布局,用百分比來定義寬度。記得要清楚浮動!
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#000}
.top{height:100px;background:#9FC;}
.main,.left,.right{height:600px;background:#F00; }
.main:after{display:table;clear:both}?
.right{float:right;background:#993; width:75%;}
.right_l,.left_l{width:5px; background:#F00; height:inherit}
.right_l{float:left;}
.right_r{float:right;}
.left{width:25%;background:#00C; float:left;}
.left_l{ float:right;}
.left_r{ float:left;}
.foot{height:50px;background:#666;}
</style>
</head>
<body>
<div class="top">21112top</div>
<div class="main"> ?
? ? <div class="right">
? ? ? <div class="right_l"></div>
? ? ? <div class="right_r">right</div>
? ? </div>
? ? <div class="left">
? ? ? <div class="left_l"></div>
? ? ? <div class="left_r">left</div>
? ? </div>
</div>
<div class="foot">foot</div>
</body>

TA貢獻(xiàn)17條經(jīng)驗 獲得超8個贊
1.左邊定寬 右邊自適應(yīng)
左邊f(xié)loat:left ? ? ? 右邊margin-left:210px
<!doctype?html> <html> <head> ????<style?type="text/css"> ????????body{? ????????????margin:0;? ????????????padding:0;? /*????????????font-size:30px;*/ ????????????color:#000; ????????} ????????.top{ ????????????height:100px; ????????????background:#9FC; ????????} ????????.main,.left,.right{ ????????????height:600px; ????????????background:#F00; ????????} ????????.right{ ???????? ???????? margin-left:210px; ???????? background:#993; ????????} ????????.left{ ???????? width:200px; ???????? background:#00C; ???????? float:?left; ????????} ????????.foot{ ???????? height:50px; ???????? background:#666; ????????} ????</style> </head> <body> <div?class="top">21112top</div> <div?class="main"> <div?class="left">left</div> <div?class="right">right</div> </div> <div?class="foot">foot</div> </body>?? </html>
2 絕對定位
<!doctype?html> <html> <head> ????<style?type="text/css"> ????????body{? ????????????margin:0;? ????????????padding:0;? /*????????????font-size:30px;*/ ????????????color:#000; ????????} ????????.top{ ????????????height:100px; ????????????background:#9FC; ????????} ????????.main{ ???????? position:?relative; ????????} ????????.main,.left,.right{ ????????????height:600px; ????????????background:#F00; ????????} ????????.right{ ???????? position:?absolute; ???????? left:?210px; ???????? top:0; ???????? background:#993; ????????} ????????.left{ ???????? width:200px; ???????? background:#00C; ????????} ????????.foot{ ???????? height:50px; ???????? background:#666; ????????} ????</style> </head> <body> <div?class="top">21112top</div> <div?class="main"> <div?class="left">left</div> <div?class="right">right</div> </div> <div?class="foot">foot</div> </body>?? </html>
。。。還有一些 各有優(yōu)缺點

TA貢獻(xiàn)16條經(jīng)驗 獲得超10個贊
兩個div都左浮動:
<!doctype?html> <html> <head> ????<meta?charset="utf-8"> ????<title>無標(biāo)題文檔</title> ????<style?type="text/css"> ????????body{?margin:0;?padding:0;?font-size:30px;?color:#000} ????????.top{height:100px;background:#9FC;} ????????.main,.left,.right{height:600px;background:#F00;} ????????.right{float:left;margin-left:10px;background:#993;} ????????.left{float:left;width:200px;background:#00C;} ????????.foot{height:50px;background:#666;} ????</style> </head> <body> <div?class="top">21112top</div> <div?class="main"> ????<div?class="left">left</div> ????<div?class="right">right</div> </div> <div?class="foot">foot</div> </body> </html>
添加回答
舉報