課程
/前端開發(fā)
/WebApp
/Hello,移動(dòng)WEB
請(qǐng)問(wèn)當(dāng)flex-direction: column; ? 父容器的高度只能用px單位 ?貌似不能用100%; ?這個(gè)怎么辦
2016-03-28
源自:Hello,移動(dòng)WEB 3-3
正在回答
<style>
html,body{height: 100%;margin: 0;padding: 0;}
#outer{height: 100%;background-color: #ffc;display: flex;flex-direction: column;}
或者h(yuǎn)eight: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>
能不能用百分比要看父元素高度是否存在
因?yàn)槭前凑崭溉萜鞯母叨葋?lái)設(shè)置百分比的 ?你說(shuō)的父容器 是因?yàn)樗母溉萜鳑](méi)有設(shè)置高度 所以不能設(shè)置% ?如果父容器的父容器 設(shè)置了高度 ?則父容器就能設(shè)置%
舉報(bào)
課程介紹移動(dòng)web的開發(fā)基礎(chǔ),排版布局,常見移動(dòng)web問(wèn)題
1 回答flex彈性布局問(wèn)題
3 回答彈性布局中,如何設(shè)置父元素高度為屏幕高度呢?
3 回答是不是將pc端布局的寬高度改為手機(jī)端的寬高度,里面的布局還是像pc端那樣寫就可以了
1 回答安卓微信內(nèi)置瀏覽器不支持flex,請(qǐng)問(wèn)老師有什么其他好用的布局方式呢?
1 回答盒布局
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-05-01
<style>
html,body{height: 100%;margin: 0;padding: 0;}
#outer{height: 100%;background-color: #ffc;display: flex;flex-direction: column;}
或者h(yuǎn)eight: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
因?yàn)槭前凑崭溉萜鞯母叨葋?lái)設(shè)置百分比的 ?你說(shuō)的父容器 是因?yàn)樗母溉萜鳑](méi)有設(shè)置高度 所以不能設(shè)置% ?如果父容器的父容器 設(shè)置了高度 ?則父容器就能設(shè)置%