課程
/前端開發
/HTML/CSS
/如何用CSS進行網頁布局
直接輸入margin:0 auto;結果和設計圖根本對不上啊,沒人發現么?header欄并沒有填滿瀏覽器,反而是main和footer填滿了
2016-03-19
源自:如何用CSS進行網頁布局 2-3
正在回答
main和footer并沒有設置width,你設置一下width:90%
你若盛開0 提問者
我的和樓主情況一樣
我打開也不是這樣的,但是在Editplus中打開 ?卻是正確的
margin:0 auto,其實就是等價于margin-top:0;margin-bottom:0;margin-left:0;margin-right:0,
輸入結果前,代碼是這樣子的:
<style type="text/css">
body{ margin:0; padding:0; font-size:30px}
div{ text-align:center; font-weight:bold}
.main,.footer{ width:960px; 【任務1】}
.head{ width:100%; height:100px; background:#ccc}
.main{ height:600px; background:#FCC;}
.footer{ height:50px; background:#9CF;}
</style>
輸入結果后可以是這樣子
.main,.footer{ width:960px;margin:0 auto; }
或
.main,.footer{ width:960px; }
.main{ height:600px; background:#FCC;margin:0 auto;}
.footer{ height:50px; background:#9CF;margin:0 auto;}
全屏點開后
舉報
用最簡潔的案例教你布局的那些知識,這是前端工程師基本技能
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-03-19
main和footer并沒有設置width,你設置一下width:90%
2016-05-25
我的和樓主情況一樣
2016-04-16
我打開也不是這樣的,但是在Editplus中打開 ?卻是正確的
2016-03-19
margin:0 auto,其實就是等價于margin-top:0;margin-bottom:0;margin-left:0;margin-right:0,
輸入結果前,代碼是這樣子的:
<style type="text/css">
body{ margin:0; padding:0; font-size:30px}
div{ text-align:center; font-weight:bold}
.main,.footer{ width:960px; 【任務1】}
.head{ width:100%; height:100px; background:#ccc}
.main{ height:600px; background:#FCC;}
.footer{ height:50px; background:#9CF;}
</style>
輸入結果后可以是這樣子
<style type="text/css">
body{ margin:0; padding:0; font-size:30px}
div{ text-align:center; font-weight:bold}
.main,.footer{ width:960px;margin:0 auto; }
.head{ width:100%; height:100px; background:#ccc}
.main{ height:600px; background:#FCC;}
.footer{ height:50px; background:#9CF;}
</style>
或
<style type="text/css">
body{ margin:0; padding:0; font-size:30px}
div{ text-align:center; font-weight:bold}
.main,.footer{ width:960px; }
.head{ width:100%; height:100px; background:#ccc}
.main{ height:600px; background:#FCC;margin:0 auto;}
.footer{ height:50px; background:#9CF;margin:0 auto;}
</style>
全屏點開后