左右布局,左边定宽,右边自适应。

Posted Sabo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了左右布局,左边定宽,右边自适应。相关的知识,希望对你有一定的参考价值。

  左右布局,左边固定宽度,右边自适应。

  自己整理的几种方法:

  页面布局如下:

  

  方法1: 左边定位,右边添加marge-left

  .div1{ width: 300px; height: 600px; background: black; position: absolute;

  .div2{height: 600px; min-width: 100px; background: red; margin-left: 300px} 

  方法2: 左边定为,右边定位(设置left)

  .div1{ width: 300px; height: 600px; background: black; position: absolute;} 

  .div2{height: 600px; min-width: 100px; background: red; position: absolute; left: 300px; } 

  方法3:左边浮动 右边浮动(右边width设置为calc(100% - 300px); 必须有空格)

  .div1{ width: 300px; height: 600px; background: black; float: left; } 

  .div2{height: 600px; width: calc(100% - 300px); background: red; float: left; } 

  方法4: 左边浮动 右边设置overflow:auto

  .div1{ width: 300px; height: 600px; background: black; float: left; } 

  .div2{ height: 600px; min-width: 200px; background: red; overflow: auto; } 

  方法5: 左边浮动 右边添加 marge-left

  .div1{ width: 300px; height: 600px; background: black; float: left; } 

  .div2{ height: 600px; min-width: 200px; background: red; marge-left:300px; } 

  效果图:

  

 

 

  

 

以上是关于左右布局,左边定宽,右边自适应。的主要内容,如果未能解决你的问题,请参考以下文章