前端开发IT@程序员猿媛

2019-04-01双飞翼布局

2019-04-01  本文已影响3人  itsmyturn

双飞翼布局(三列布局,两边固定中间自适应)

一 float浮动版本

<html >
<head>
    <meta charset="UTF-8">
    <title>双飞翼布局</title>
</head>
<style type="text/css">
*{
    margin:0;
    padding: 0;
}
html,body{
    height:100%;
}
.clearfix:after{
    clear:both;
    display:block;
    content:'';
}
.wrap{
    width:100%;
}
.one{
    float: left;
    width: 100px;
    margin-right: -100px;
    background: yellow;
    min-height: 100px;
}
.three{
    float: right;
    width: 100px;
    margin-left: -100px;
    min-height: 100px;
    background: green;
}
.wrap_two{
    width: 100%;
    float: left;
}
.two{
    margin: 0 110px 0 110px;
    min-height: 100px;
    background: purple;
}

</style>
<body>
    <div class="wrap clearfix">
        <div class="one"></div>
        <div class="wrap_two">
            <div class="two"></div>
        </div>
        <div class="three"></div>
    </div>
</body>
</html>

二,flex版

<html >
<head>
    <meta charset="UTF-8">
    <title>双飞翼布局</title>
</head>
<style type="text/css">
*{
    margin:0;
    padding: 0;
}
html,body{
    height:100%;
}
#outer{
    display: flex;
    width: 100%;
    flex-flow: row nowrap;
}
.left,.right{
    width:200px;
    height:50px;
    background: red;
}
.middle{
    flex-grow: 1;
    background: yellow;
}
</style>
<body>
    <div id="outer">
        <div class="left">left</div>
        <div class="middle">middle</div>
        <div class="right">right</div>
    </div>
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读