三栏布局,div左右盒子是定宽,中间是自适应

用弹性布局flex:

给父盒子加个display:flex; 给中间盒子设flex=1;

   /* 弹性盒子布局*/
.wrap{
width: 100%;
height: 90px;
display: flex;
}
.left{
width: 300px;
height: 90px;
background-color: red;
float: left;
}
.content{
flex:1;
height: 90px;
background-color: yellow;
}
.right{
width: 300px;
height: 90px;
background-color:blue;
float: right;
}
</style>
</head>
<body>
<div class="wrap">
<div class="left"></div>
<div class="content"></div>
<div class="right"></div>
</div>

 

posted @ 2017-12-22 14:00  web小白需努力  阅读(1103)  评论(0编辑  收藏  举报