HTML样式
<div class="example">
<div class="left">left</div>
<div class="right"></div>
</div>
第一种方法:position
CSS样式
.example{
position:relation;
width:60%;
}
.example .left{
position:absolute;
left:0;
width:100px;
background:#f00;
}
.example .right{
background:#0f0;
}
第二种方法:float
.example{
width:60%;
}
.example .left{
float:left;
width:100px;
background:#f00;
}
.example .right{
background:#0f0;
}
第三种方法:display:table
CSS样式
.example{
display:table;
width:60%;
}
.example .left{
display:table-cell;
width:100px;
background:#f00;
}
.example .right{
display:table-cell;
background:#0f0;
}
本文介绍了三种实现网页左右布局的方法:使用position属性、float属性以及display属性设置为table的方式。每种方法都通过具体的CSS样式代码进行了详细说明。
5017

被折叠的 条评论
为什么被折叠?



