div自适应填充剩余宽度的方法

两个DIV,左侧的div宽度固定,右侧DIV自适应填满剩下的宽度。

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>demo</title>
    <style type="text/css">
        #wrap{
            padding-left: 200px;
        }
        .leftpart{
            float:left;
            width:200px;
            margin-left:-200px;
            height: 200px;
            background-color:lightgreen;
        }
        .rightpart{
            float: right;
            width: 100%;
            height: 200px;
            background-color: lightseagreen;
        }
    </style>
</head>
<body>
<div id="wrap">
    <div class="rightpart">宽度自适应部分</div>
    <div class="leftpart">width200的左边栏</div>
</div>
</body>
</html>

效果如图

 转自   https://blog.csdn.net/weixin_41804384/article/details/81000291

 

posted @ 2019-07-01 17:14  猪脚踏浪  阅读(6195)  评论(0编辑  收藏  举报