美文网首页
3个div 三个div横向并排

3个div 三个div横向并排

作者: 迪爷 | 来源:发表于2017-04-07 09:39 被阅读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>

相关文章

网友评论

      本文标题:3个div 三个div横向并排

      本文链接:https://www.haomeiwen.com/subject/katgrttx.html