3 回答

TA貢獻211條經驗 獲得超152個贊
像你這種定位方法的話,錯誤有三:
1、布局錯誤,right和left的位置
2、.right{background:#9f9;height:600px;margin-left:210px;position:absolute;width:100%}中不能給絕對定位,一絕對定位就脫離了文檔流
3、還是上面那句,right不能給width為100%,這樣會讓right的寬度等于main的寬度

TA貢獻211條經驗 獲得超152個贊
<!DOCTYPE html>
<html>
<head>
? ?<meta http-equiv="content-type" content="text/html; charset=utf-8" />
? ?<title>混合布局編程挑戰</title>
? ?<style type="text/css">
? ? ? ?body{ margin:0; padding:0; font-size:30px; color:#fff;width:100%}
? ? ? ?.top{height:50px;background:#ccc}
? ? ? ?.main{width:100%;height:600px;background:pink;margin:0 auto;}
? ? ? ?.left{ width:200px;background:#f90;height:600px;float:left}
? ? ? ?.right{background:#9f9;height:600px;margin-left:210px;}
? ? ? ?.foot{height:50px;background:#fcc;}
? ? ? ?/*任務1:完成頂部(top)、底部(foot)寬度自適應
? ? ? ?任務2:中間分為2兩欄,其中,左側(left)寬度為200px, 右側(right)寬度自適應
? ? ? ?任務3:要求右側(right)先加載,左側(left)后加載
? ? ? ?任務4:編寫的代碼要兼容ie6*/
? ?</style>
</head>
<body>
<div class="top">top</div>
<div class="main">
? ?<div class="left">left</div>
? ?<div class="right">right</div>
</div>
<div class="foot">foot</div>
</body>
</html>
- 3 回答
- 1 關注
- 2007 瀏覽
相關問題推薦
添加回答
舉報