您的位置:首页 > Web前端 > CSS

div+css左侧固定宽度200px,右侧自动扩展

2017-10-31 09:58 706 查看


<div id="lt"></div>
<div id="rt"></div>

一、左边固定,右边自适应的布局

1. 左边左浮动,右边加个overflow:hidden;
#lt{ float: left;width:200px; background: #ff0;}
#rt{ overflow: hidden; background: #f0f;}

2. 左边左浮动,右边加个margin-left;
#lt{ float: left; width:200px; background: #ff0;}
#rt{ margin-left: 200px; background: #f0f;}

3. 左边绝对定位,右边加个margin-left;
#lt{ position: absolute; top:0; left:0; width:200px; background: #ff0;}
#rt{ margin-left: 200px; background: #f0f;}

4. 左右两边绝对定位,右边加个width,top,left,right
#lt{ position: absolute; top:0 ; left:0 ;width:200px; background: #ff0;}
#rt{ position: absolute; top:0 ; left:200px; width: 100% ; rigth:0;background: #f0f;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐