1. 程式人生 > >左邊div固定寬度,右邊div寬度自適應

左邊div固定寬度,右邊div寬度自適應

http://www.zhihu.com/question/37208845
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<style>
    body{
        padding: 0px;
        margin: 0px;
    }
    .wrap{
        width: 100%;
        height:500px;
        background:red;
    }
    #dv1{
        position:absolute;
        top:0px;
        left:0px;
        width: 200px;
        height: 500px;
        background:yellow;
        /*display: inline-block;*/
    }
    #dv2{
        /*display: inline-block;*/
        /*width: auto;*/
        height:500px;
        background: green;
        margin-left: 200px;
    }
    .wrap2{
        width: 100%;
        height: 500px;
        
    }
</style>
<body>
<div class="wrap">
    <div id="dv1"></div>
    <div id="dv2"></div>
</div>
<div class="wrap2"></div>
</body>
</html>