3个div 三个div横向并排
2017-04-07 本文已影响0人
迪爷
1
<div style="height:100px;width:200px; float:left;background-color:red"> </div>
<div style="height:100px; width:200px; float:left;background-color:green"> </div>
<div style=" height:100px; width:200px; float:left;background-color:black"> </div>
注意对div设置宽度和高度,不然显示不出来,div默认没有宽高。
2
<div style="height:100px;width:200px; display:inline-block;background-color:red;margin-right:20px"> </div>
<div style="height:100px; width:200px; display:inline-block;background-color:green;margin-right:20px"> </div>
<div style=" height:100px; width:200px; display:inline-block;background-color:black;margin-right:20px"> </div>
还是给个magin吧,看起来好看点。
3 弹性布局
<div style="display:flex; ">
<div style="height:100px;width:200px; background-color:red;margin-right:20px"> </div>
<div style="height:100px; width:200px; background-color:green;margin-right:20px"> </div>
<div style=" height:100px; width:200px; background-color:black;margin-right:20px"> </div>
</div>