怎样使3个DIV水平排列,css怎么写呢?我搞来搞去它们都是垂直排列的

如题所述

<style>
#box{width:900px;height:300px;margin:0 auto}
#box div{width:300px;height:300px;float:left;text-align:center;line-height:300px;color:#fff}
.bg1{background:#f00}
.bg2{background:#0f0}
.bg3{background:#00f}
</style>
<div id="box">
<div class="bg1">1</div>
<div class="bg2">2</div>
<div class="bg3">3</div>
</div>
温馨提示:内容为网友见解,仅供参考
第1个回答  2017-08-20
使用flex布局,或者浮动,或者inline-block等
相似回答