全屏布局-網(wǎng)易云課堂微專業(yè)-頁面架構(gòu)-布局解決方案

Methods ①:position

兼容性:IE6不支持
解決方案:http://nec.netease.com/library/141027

<div class="parent">
    <div class="top"></div>
    <div class="left"></div>
    <div class="right">
        <div class="inner">right</div> <!--嵌套滾動條-->
    </div>
    <div class="bottom"></div>
</div>
<style>
   html, body, .parent {
       height: 100%;
       overflow: hidden
   }

   .top {
       position: absolute;
       top: 0;
       left: 0;
       right: 0;
       /*height: 100px;*/
       height: 10%;
       background: red;
   }

   .left {
       position: absolute;
       left: 0;
       /*top: 100px;*/
       top: 10%;
       /*bottom: 50px;*/
       bottom: 5%;
       /*width: 200px;*/
       width: 20%;
       background: green;
   }

   .right {
       position: absolute;
       overflow: auto;
       /*left: 200px;*/
       left: 20%;
       right: 0;
       /*top: 100px;*/
       top: 10%;
       /*bottom: 50px;*/
       bottom: 5%;
       background: blue;
   }

   .bottom {
       position: absolute;
       left: 0;
       right: 0;
       bottom: 0;
       /*height: 50px;*/
       height: 5%;
       background: orange;
   }

   .right.inner {
       min-height: 1000px;
   }
</style>

Methods ②:flex

兼容性:IE9及以下不支持

<div class="parent">
    <div class="top"></div>
    <div class="middle">
        <div class="left"></div>
        <div class="right">
            <div class="inner">right</div> <!--嵌套滾動條-->
        </div>
    </div>
    <div class="bottom"></div>
</div>
<style>
   html,body,.parent{
       height: 100%;
       overflow: hidden;
   }
   .parent{
       display: flex;
       flex-direction: column;
   }
   .top{
       /*height: 100px;*/
       height: 10%;
       background: red;
   }
   .bottom{
       /*height: 50px;*/
       height: 5%;
       background: green;
   }
   .middle{
       flex: 1;display: flex;
   }
   .left{
       /*width: 200px;*/
       width: 20%;
       background: blue;
   }
   .right{
       flex: 1;
       overflow: auto;
       background: orange;
   }

   .right.inner {
       min-height: 1000px;
   }
</style>

Methods ③:top、left、bottom內(nèi)容自適應(yīng)

方案:
flex
grid:W3C草案

<div class="parent">
    <div class="top"></div>
    <div class="middle">
        <div class="left"></div>
        <div class="right">
            <div class="inner">right</div> <!--嵌套滾動條-->
        </div>
    </div>
    <div class="bottom"></div>
</div>
<style>
   html,body,.parent{
       height: 100%;
       overflow: hidden;
   }
   .parent{
       display: flex;
       flex-direction: column;
   }
   .top{
       /*height: 100px;*/ //去除
       height: 10%; //去除
       background: red;
   }
   .bottom{
       /*height: 50px;*/ //去除
       height: 5%; //去除
       background: green;
   }
   .middle{
       flex: 1;display: flex;
   }
   .left{
       /*width: 200px;*/ //去除
       width: 20%;//去除
       background: blue;
   }
   .right{
       flex: 1;
       overflow: auto;
       background: orange;
   }

   .right.inner {
       min-height: 1000px;
   }
</style>
方案 兼容性 性能 自適應(yīng)
position 部分自適應(yīng)
flex 較差 可自適應(yīng)
grid 較好 可自適應(yīng)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容