css布局之2边固定宽度,中间自适应

左右两列分别左浮动和右浮动并给一个固定宽度,中间不浮动,也不设定宽度。

<div class="left">1</div>
<div class="right">2</div>
<div class="center">3</div>

 <style>
        .left{
            width: 200px;
            background: red;
            float: left;
        }
        .right{
            width: 300px;
            background: blue;
            float: right;
        }
        .center{
            margin:0 300px 0 200px;
            background: orange;
        }
        div{
            min-height: 500px;
        }
    </style>

2边固定宽度,中间自适应

补充:注意<div class="left">1</div> <div class="center">3</div> <div class="right">2</div>
这样写的,因为center为块级元素,会占一行,就算right浮动了,因为center占一行,会被挤到下一层。要注意在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43743956/article/details/84817275