双栏布局

左边固定,右边自适应

1.左边浮动,右边自适应

//html
//css .content{overflow:hidden;height:200px;} .left{ display:inline-block; float:left; width:200px; height:200px; background:red; } .right{ display:block; height:200px; background:yellow; }

 

2.利用定位

//html
//css .content{ position: relative; } .left{ display: inline-block; height: 200px; width: 200px; position: absolue; top: 0; float: left; background: red; } .right{ display: block; height: 200px; background: yellow; margin-left: 200px; }

3.负margin方法

//html
//css .left{ display: inline-block; width: 200px; height: 200px; margin-left: -100%; background: red; float: left; } .content{ width: 100%; float: left; } .right{ display: block; background: yellow; margin-left: 200px; height: 200px; }

4.利用flex布局;

//html
//css .content{ display: flex; } .left{ width: 200px; height: 200px; display: inline-block; background: red; } .right{ flex: 1; background: yellow; }

 

转载于:https://www.cnblogs.com/xxcnhj/p/11171991.html

你可能感兴趣的:(双栏布局)