3个div 三个div横向并排

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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,680评论 1 92
  • CSS 3中弹性盒布局的最新版概述 在CSS 3中,CSS Flexible Box模块为一个非常重要的模块,该模...
    吾名无双阅读 4,968评论 0 5
  • 收听音频,戳链接,旧号itclan已暂停使用,欢迎关注微信itclanCoder公众号可收听更多音频 前言 关于网...
    itclanCoder阅读 12,529评论 3 30
  • 前言 温馨提示:本文较长,图片较多,本来是想写一篇 CSS 布局方式的,但是奈何 CSS 布局方式种类太多并且实现...
    sunshine小小倩阅读 8,338评论 0 59
  • 看《超级演说家》的时候,记忆最深刻的是刘媛媛参加总决赛时的演说——《寒门贵子》,当时觉得她讲得很精彩,慢慢的在学习...
    饭小艺阅读 1,287评论 4 9