課程
/前端開發
/HTML/CSS
/如何用CSS進行網頁布局
設置left為絕對定位后,并設置定寬200px后,right不設置寬度,那right的寬度為什么是main的寬度減去left的寬度?
2016-12-27
源自:如何用CSS進行網頁布局 5-3
正在回答
個人認為:right和left是在main下的塊狀元素,屬于塊嵌套著塊,當left設定了絕對定位后,right不設置寬度為自適應,所以寬度為main的寬度減去left的寬度。
->我的答案,親測無誤。
.top{width:100%;background:gray;height:50px;}
.main{width:100%;background:red;height:500px;}
.left{ width:30%;float:left; background:blue;height:500px;}
.right{width:70%;float:right; background:green;height:500px;}
.foot{width:100%;background:orange;height:100px;}
舉報
用最簡潔的案例教你布局的那些知識,這是前端工程師基本技能
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-12-27
個人認為:right和left是在main下的塊狀元素,屬于塊嵌套著塊,當left設定了絕對定位后,right不設置寬度為自適應,所以寬度為main的寬度減去left的寬度。
->我的答案,親測無誤。
.top{width:100%;background:gray;height:50px;}
.main{width:100%;background:red;height:500px;}
.left{ width:30%;float:left; background:blue;height:500px;}
.right{width:70%;float:right; background:green;height:500px;}
.foot{width:100%;background:orange;height:100px;}