課程
/前端開發
/WebApp
/Hello,移動WEB
請問當flex-direction: column; ? 父容器的高度只能用px單位 ?貌似不能用100%; ?這個怎么辦
2016-03-28
源自:Hello,移動WEB 3-3
正在回答
<style>
html,body{height: 100%;margin: 0;padding: 0;}
#outer{height: 100%;background-color: #ffc;display: flex;flex-direction: column;}
或者height:400px;
.inner{height: 40%;flex: 1 1 auto;margin-bottom:20px;background-color: #ddf;}
</style>
<body>
<div id="outer">
<div class="inner"></div>
</div>
</body>
能不能用百分比要看父元素高度是否存在
因為是按照父容器的高度來設置百分比的 ?你說的父容器 是因為它的父容器沒有設置高度 所以不能設置% ?如果父容器的父容器 設置了高度 ?則父容器就能設置%
舉報
課程介紹移動web的開發基礎,排版布局,常見移動web問題
1 回答flex彈性布局問題
3 回答彈性布局中,如何設置父元素高度為屏幕高度呢?
3 回答是不是將pc端布局的寬高度改為手機端的寬高度,里面的布局還是像pc端那樣寫就可以了
1 回答安卓微信內置瀏覽器不支持flex,請問老師有什么其他好用的布局方式呢?
1 回答盒布局
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-05-01
<style>
html,body{height: 100%;margin: 0;padding: 0;}
#outer{height: 100%;background-color: #ffc;display: flex;flex-direction: column;}
或者height:400px;
.inner{height: 40%;flex: 1 1 auto;margin-bottom:20px;background-color: #ddf;}
</style>
<body>
<div id="outer">
<div class="inner"></div>
<div class="inner"></div>
</div>
</body>
能不能用百分比要看父元素高度是否存在
2016-03-29
因為是按照父容器的高度來設置百分比的 ?你說的父容器 是因為它的父容器沒有設置高度 所以不能設置% ?如果父容器的父容器 設置了高度 ?則父容器就能設置%