鍍金池/ 問答/HTML/ css如何布局

css如何布局

說一下布局情況:
左右布局(其中左方寬度固定,右方自適應(yīng))
右方:上中下布局,中間高度自適應(yīng),上下固定

clipboard.png

大家的回家都很有效,謝謝各位。按時(shí)間順序來,采納第一個(gè)。

回答
編輯回答
陪妳哭

寫一個(gè)非flex版的

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
        *{box-sizing: border-box;margin: 0;padding: 0;}
        html,body{height:100%;width:100;}
        .box{
            width: 100%;
            height: 100%;
            border: 1px solid red;
        }
        .left{
            width:200px;
            height:100%;
            background: #f00;
            float: left;
        }
        .right{
            width: calc(100% - 200px);
            height:100%;
            background: #0f0;
            padding: 200px 0;
            position: relative;
            float: right;
        }
        .top,.bottom{
            position: absolute;
            background:#00f;
            height:200px;
            width: 100%;
        }
        .top{top:0;}
        .bottom{bottom:0;}
        .mid{width:100%;height:100%}
    </style>
</head>
<body>
    <div class="box">
        <div class="left"></div>
        <div class="right">
            <div class="top"></div>
            <div class="mid"></div>
            <div class="bottom"></div>
        </div>
    </div>
</body>
</html>
2017年7月13日 10:57
編輯回答
離人歸

希望對(duì)你有所幫助!


直接復(fù)制粘貼運(yùn)行便可看到效果:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            text-align: center;
        }
        html, body {
            width: 100%;
            height: 100%;
        }
        .box {
            position: relative;
            width: 100%;
            height: 100%;
        }
        .left_main {
            float: left;
            width: 300px;
            height: 100%;
            background: red;
        }
        .right_main {
            position: relative;
            float: left;
            width: calc( 100% - 300px );
            height: 100%;
        }
        .right_main .right_top, .right_main .right_bottom{
            position: absolute;
            width: 100%;
            height: 100px;
            left: 0;
        }
        .right_main .right_top {
            top: 0;
            background: orange;
        }
        .right_main .right_bottom {
            bottom: 0;
            background: green;
        }
        .right_main .right_middle {
            position: relative;
            top: 100px;
            width: 100%;
            height: calc( 100% - 100px - 100px );
            background: yellow;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="left_main">左邊固定寬度</div>
        <div class="right_main">
            <div class="right_top">上方固定高度</div>
            <div class="right_middle">中間高度自適應(yīng)</div>
            <div class="right_bottom">下方固定高度</div>
        </div>
    </div>
</body>
</html>

運(yùn)行效果圖

clipboard.png

2018年4月12日 20:50
編輯回答
熟稔

正常就這樣吧,一個(gè)屏幕的話。
有碼,點(diǎn)擊查看>>

2018年7月28日 22:13