左边固定宽度右边自适应的三种方法

来源:互联网 发布:dota2数据分析网站 编辑:程序博客网 时间:2024/05/08 22:19

<div class="both">    <div class="left"></div>    <div class="right"></div></div>

一、用flex

.both{    height:500px;    display:flex;    flex-direction: row;}.left{    background:red;    width:200px;}.right{    flex:1;    background:blue;}
二、float

.both{    height:500px;    overflow:auto;    *zoom:1;}.left{    background:red;    width:200px;    float:left;    height:100%;}.right{    margin-left:200px;    background:blue;    height:100%;}
三、定位

.both{    height:500px;    position:relative;}.left{    background:red;    position:absolute;    width:200px;    left:0;    height:100%;}.right{    background:blue;    margin-left:200px;    height:100%;}

阅读全文
0 0
原创粉丝点击