亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

橫向兩列布局

<!DOCTYPE HTML>

<html>

? ? <head>

? ? <meta http-equiv="Content-Type" content="text/html;charset=utf-8">

? ? ? ? ?<title>橫向兩列布局</title>

? ? ? ? <style type="text/css">

? ? ? ? ? ? *{margin:0;padding:0;}

? ? ? ? ? ? #wrap{width:960px;text-align:center;background:#ccc;margin:0 auto;}

? ? ? ? ? ? #header{height:30px;background:orange;}

? ? ? ? ? ? #mainBody{height:500px;width:100%;background:yellow;overflow:hidden;}

? ? ? ? ? ? .left{width:700px;height:150px; background:black;float:left;}

? ? ? ? ? ? .right{height:500px;background:green;float:right;margin-left:710px;}

? ? ? ? ? ? #footer{height:100px;background:purple;bottom:0;}

? ? ? ? </style>

? ? </head>

? ? <body>

? ? ? ? <div id="wrap">

? ? ? ? ? ? <div id="header">header</div>

? ? ? ? ? ? <div id="mainBody">mainBody

? ? ? ? ? ? ? ? <div class="left">left</div>

? ? ? ? ? ? ? ? <div class="right">right</div>

? ? ? ? ? ? </div>

? ? ? ? ? ? <div id="footer">footer</div>

? ? ? ? </div>

? ? </body>

</html>為什么我右邊的視圖出來沒有right呢,??

正在回答

4 回答

把margin-left:710px;改成margin-left:10px;就可以了 ? 按照你原先的寫法 中間的間距有710PX 那么大

0 回復 有任何疑惑可以回復我~

.right{height:500px;background:green;float:right;margin-left:710px;}中?margin-left:710px; 不妥,left占了左邊700px,只剩260px,你卻要710px,只好另起行,畢竟不是用position 相對位置與絕對位置,這種情況下用%比較好吧。.left的width 80%,.right的 18%……你自己調吧

0 回復 有任何疑惑可以回復我~

<!DOCTYPE HTML>

<html>

? ? <head>

? ? <meta http-equiv="Content-Type" content="text/html;charset=utf-8">

? ? ? ? ?<title>橫向兩列布局</title>

? ? ? ? <style type="text/css">

? ? ? ? ? ? *{margin:0;padding:0;}

? ? ? ? ? ? #wrap{width:960px;text-align:center;background:#ccc;margin:0 auto;}

? ? ? ? ? ? #header{height:30px;background:orange;}

? ? ? ? ? ? #mainBody{height:500px;width:100%;background:yellow;overflow:hidden;}

? ? ? ? ? ? .left{width:700px;height:150px; background:black;float:left;}

? ? ? ? ? ? .right{height:500px;background:green;width:250px;position:relative;top:0;left:710px;}

? ? ? ? ? ? #footer{height:100px;background:purple;bottom:0;}

? ? ? ? </style>

? ? </head>

? ? <body>

? ? ? ? <div id="wrap">

? ? ? ? ? ? <div id="header">header</div>

? ? ? ? ? ? <div id="mainBody">

? ? ? ? ? ? ? ? <div class="left">left</div>

? ? ? ? ? ? ? ? <div class="right">right</div>

? ? ? ? ? ? </div>

? ? ? ? ? ? <div id="footer">footer</div>

? ? ? ? </div>

? ? </body>

</html>

您看看。右邊您用相對定位可以實現

0 回復 有任何疑惑可以回復我~

怎么粘貼不了我的視圖呢,真是無語!

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
網頁布局基礎
  • 參與學習       214662    人
  • 解答問題       1833    個

讓你精通CSS中三大定位機制,徹底掌握網頁布局的相關知識

進入課程

橫向兩列布局

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號