鍍金池/ 問答/HTML5  PHP  HTML/ Css用DIV頁面布局(按照比例劃分)寬高如何設(shè)置?

Css用DIV頁面布局(按照比例劃分)寬高如何設(shè)置?

混亂DIV布局
1想要DIV按照屏幕百分比顯示?
2如何要整體的布局自適應(yīng)屏幕?
如圖:圖片描述

回答
編輯回答
離殤

下面兩塊就不用說了吧,就是有高度的div
上邊那個或者把1左浮動?;蛘甙?3右浮動。父級清一下浮動就可以了。這沒啥難度吧。

2018年4月17日 00:57
編輯回答
脾氣硬

自適應(yīng)高度么?

2018年9月22日 07:06
編輯回答
蟲児飛
<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        body{
            display: grid;
            grid-template-areas: 'first second'
                                 'first thrid'
                                 'four four'
                                 'five five';
            grid-template-rows: 10vh 10vh 60vh 20vh;
            grid-auto-columns: 200px 1fr;
        }
        div:nth-of-type(1){
            grid-area: first;
            background: red;
        }

        div:nth-of-type(2){
            grid-area: second;
            background: yellow;
        }

        div:nth-of-type(3){
            grid-area: thrid;
            background: green;
        }

        div:nth-of-type(4){
            grid-area: four;
            background: yellow;
        }

        div:nth-of-type(5){
            grid-area: five;
            background: green;
        }
    </style>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<script>
</script>
</body>
</html>
2018年5月29日 06:31
編輯回答
莓森
<style>
        .wrap {
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 100%;
        }
        
        .top {
            height: 20%;
            background: red
        }
        
        .top-left {
            width: 20%;
            height: 100%;
            float: left;
            background: blue
        }
        
        .top-right {
            height: 50%;
            overflow: hidden;
            background: green
        }
        
        .middle {
            height: 60%;
            background: yellow
        }
        
        .bottom {
            height: 20%;
            background: tomato
        }
    </style>
    <div class="wrap">
        <div class="top">
            <div class="top-left"></div>
            <div class="top-right"></div>
            <div class="top-right" style="background:springgreen"></div>
        </div>
        <div class="middle"></div>
        <div class="bottom"></div>
    </div>
2018年8月31日 06:36
編輯回答
久礙你
.flexBox {
  display: -webkit-flex;
  display: flex;
  height: 400px;
  -webkit-flex-direction: column;
  flex-direction: column;
}
.topBox {
  position: relative;
  -webkit-flex: 0 0 20%;
  flex: 0 0 20%;
}
.topFlexBox {
  position: absolute;
  display: -webkit-flex;
  display: flex;
  width: 100%;
  height: 100%;
  background-color: #000;
}

.first {
  -webkit-flex: 0 0 20%;
  flex: 0 0 20%;
  background-color: #3781B5;
}

.secondBox {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100%;
  -webkit-flex: 0 0 80%;
  flex: 0 0 80%;
}

.second {
  -webkit-flex: 0 0 50%;
  flex: 0 0 50%;
  background-color: #13C723;
}

.third {
  -webkit-flex: 0 0 50%;
  flex: 0 0 50%;
  background-color: #E33728;
}

.fourth {
  -webkit-flex: 0 0 60%;
  flex: 0 0 60%;
  background-color: #E3E13B;
}

.fifth {
  -webkit-flex: 0 0 20%;
  flex: 0 0 20%;
  background-color: #9DE3CC;
}

<div class="flexBox">
  <div class="topBox">
    <div class="topFlexBox">
      <div class="first"></div>
      <div class="secondBox">
        <div class="second"></div>
        <div class="third"></div>
      </div>
    </div>
  </div>
  <div class="fourth"></div>
  <div class="fifth"></div>
</div>

codePen
修改了一下,chrome、搜狗、iPhone都可以正常顯示了

2017年9月12日 07:32