課程
/前端開發
/HTML/CSS
/如何用CSS進行網頁布局
用浮動怎么讓寬度自適應?
2016-07-25
源自:如何用CSS進行網頁布局 5-3
正在回答
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#fff}
.top{height:100px; background:#ccc;}
.left{ width:200px;float:left; height:300px; background-color: #9CF}
.right{margin-right:210px;background:#F90; width:100%;}
.foot{height:50px; background:#F90;clear:both;}
</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>
王小明大人 提問者
寬度自適應就是不設置width的值,只設置height的值。這樣他就默認是width:100%即充滿父元素。
ni wenwen qita ren?
舉報
用最簡潔的案例教你布局的那些知識,這是前端工程師基本技能
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-07-25
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#fff}
.top{height:100px; background:#ccc;}
.left{ width:200px;float:left; height:300px; background-color: #9CF}
.right{margin-right:210px;background:#F90; width:100%;}
.foot{height:50px; background:#F90;clear:both;}
</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>
2016-07-25
寬度自適應就是不設置width的值,只設置height的值。這樣他就默認是width:100%即充滿父元素。
2016-07-25
ni wenwen qita ren?