課程
/前端開發
/HTML/CSS
/網頁布局基礎
position:absolute
margin-left:200px(可以換成left:200px)嗎
2015-09-19
源自:網頁布局基礎 4-4
正在回答
http://www.xianlaiwan.cn/qadetail/56441這個人講的蠻清楚的
<html><head> <style?type="text/css"> *{margin:0;padding:0} .box1{background:#ff0000;height:150px;} .box2{background:#00ff00;height:100px;position:absolute;margin-left:100px;margin-top:50px;top:10px} .box3{background:#0000ff;height:120px;} </style> </head> <body> ????<div?class="box1">box1</div> ????<div?class="box3">box3<div?class="box2">box2</div></div> </body> </html>
可以 但是他會脫離文檔流 要小心布局
洪小仔
小炮夫
舉報
讓你精通CSS中三大定位機制,徹底掌握網頁布局的相關知識
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-06-02
http://www.xianlaiwan.cn/qadetail/56441
這個人講的蠻清楚的
2016-06-02
//我個人的理解是margin對應自己的上一個或父標簽,而top是對應根標簽(<html>).<html><head> <style?type="text/css"> *{margin:0;padding:0} .box1{background:#ff0000;height:150px;} .box2{background:#00ff00;height:100px;position:absolute;margin-left:100px;margin-top:50px;top:10px} .box3{background:#0000ff;height:120px;} </style> </head> <body> ????<div?class="box1">box1</div> ????<div?class="box3">box3<div?class="box2">box2</div></div> </body> </html>2015-09-21
可以 但是他會脫離文檔流 要小心布局