左右布局,一边自适应,一边固定

2019-05-06  本文已影响0人  瘾_95f1
<!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;
        }
        .app {
            clear: both;
        }
        .left {
            background: #eee;
            padding: 20px;
            overflow: hidden;
            height: 300px;
            word-break: break-all;
        }
        /* float: left   改为left就可以变成左固定,右自适应*/
        .right{
            float: right;
            background: blue;
            width: 300px;
            height: 300px;
            padding: 20px;
            word-break: break-all;
        }
        .q {
            width: 100%;
            height: 20px;
            background: red;
            margin-top: 50px;
        }
    </style>
</head>
<body>
    <div class="app">
        <div class="right">
            888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
            <div class="q">宽度100%</div>
        </div>
        <div class="left">
            888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
            <div class="q">宽度100%</div>
        </div>
    </div>
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读