码迷,mamicode.com
首页 > 其他好文 > 详细

两列布局方式

时间:2017-01-01 13:24:06      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:fixed   css   relative   ie6   ati   abs   play   div   content   

两列布局方式:
1、float IE6 有3px偏移 在left上加 margin-left: -100px
.left{
background-color: red;
float: left;
width: 100px

}
.right{
background-color: green;
margin-left: 110px

}

<div class="content">
<div class="left">left</div>
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>


2、float+margin+fix用float:left 和right
<div class="content">
<div class="left">left</div>
<div class="right-flx">
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>
</div>

.left{
background-color: red;
float: left;
width: 100px;
position: relative;

}
.right{
background-color: green;
margin-left: 100px

}
.right-fix{
background-color: blue;
float: right;
width:100%;
margin-left: 100px

}


3、overflow

.left{
background-color: red;
float: left;
width: 100px;


}
.right{
background-color: green;
overflow: hidden;

}
<div class="content">
<div class="left">left</div>
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>

4、table
.content{
display: table;
width: 100%;
table-layout: fixed;

}
.left,.right{
display: table-cell;
}
.left{
background-color: red;
width: 100px;
}
.right{
background-color: green;
}

<div class="content">
<div class="left">left</div>
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>

5、flex css3
.content{
display: flex;

}

.left{
background-color: red;
width: 100px;
margin-right: 20px;
}
.right{
background-color: green;
flex:1;
}
<div class="content">
<div class="left">left</div>
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>


6 display +position
.content{
position: relative;

}

.left{
background-color: red;
width: 100px;
display: inline-block;
}
.right{
background-color: green;
position: absolute;
left: 110px;
width: 100%;
top:0;
}
<div class="content">
<div class="left">left</div>
<div class="right">
<p class="e">qqq</p>
<p>2w</p>
</div>
</div>

两列布局方式

标签:fixed   css   relative   ie6   ati   abs   play   div   content   

原文地址:http://www.cnblogs.com/coding4/p/6240910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!