這節課發現一個問題,對于新手來說絕對是一個問題
這一課程老師在最后一節編程挑戰里挖了個坑,我不知道老師是有意思為之還是弄錯了,
任務2:中間分為2兩欄,其中,左側(left)寬度為200px, 右側(right)寬度自適應
<body>
<div class="top">top</div>
<div class="main">
? ? <div class="right">right</div>
? ? <div class="left">left</div>
</div>
<div class="foot">foot</div>
如果按照任務來的話CSS代碼是這樣寫的
.left{background:#0000FF;height:500px;width:200px;float:left;}
.right{background:#00CC99;height:500px;margin-left:210px;}
但是這樣寫出來布局就是亂的
原因就是(main)里的(right)和(left)順序寫錯了
應該
<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>
要么就改CSS部分
.right{background:#0000FF;height:500px;width:200px;float:left;}
.left{background:#00CC99;height:500px;margin-left:210px;}
反正就是兩個部分順序要改一下,不然達不到任務的要求。
2016-08-23
任務3:要求右側(right)先加載,左側(left)后加載
所以應該給left添加樣式:position:absolute;left:0;top:100px;
這樣的話就可以了
2016-08-23
<div class="right">right</div>
? ? <div class="left">left</div>
可能是順序寫錯了;
光用浮動達不到要求效果;
除非使用絕對定位;
.left{ width:37%; height:300px;background:blue;position:absolute; top:0px; left:0px;}
.right{width:61%; height:300px;background:green;float:right; ? ? }