使多个div并列一行的方法是将div的css样式设知定为浮动方式:float:left;或者是设定为inline-block行内块元道素【ie6下设置为inline行内元素已保证兼容性】。版
前提是几个div宽度总和不能超出父元素的宽度。
class="d1
clearfix">
class="d1-1">
class="d1-2">
class="d1-3">
css:
.d1{
width:1200px;
margin:0
auto;
overflow:hidden;}
.d1
div{
float:left;/*将块元素div设定权为左浮动*//*display:inline-block;
_display:inline;*/
width:400px;
height:150px;
background:#ccc;}