html - 包含元素时,Css div 内联不相邻

标签 html css

Css 总是给我带来新的惊喜。

我想要 4 个 div 并排排列(或 2 和 2,取决于父级大小) 只要它们是空的,它就可以工作。如所附示例所示,一旦获取内容就会中断。

我很困惑。一个 div 的内容如何影响一个完整的不相关的 div?

.statistictable{
    display: inline-block;
    margin:20px;
    width: 300px;
    height:100px;
    background: #D9EFFF;
}
.statistics{
  border-bottom:5px solid;
}
<div class="statistics">
    <div class="statistictable">
I'am breaking!!!

    </div>
    <div class="statistictable">

    </div>
    <div class="statistictable">

    </div>
    <div class="statistictable">

    </div>
</div>
<div class="statistics">
    <div class="statistictable">


    </div>
    <div class="statistictable">

    </div>
    <div class="statistictable">

    </div>
    <div class="statistictable">

    </div>
</div>

最佳答案

我会使用 span 标签而不是 div,因为默认情况下 span 是内联的。这是否给出了预期的结果?

例如

<div class="statistics">
<span class="statistictable">


</span>
<span class="statistictable">
</span>
<span class="statistictable">

</span>
<span class="statistictable">

</span>
</div>

关于html - 包含元素时,Css div 内联不相邻,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37032369/

相关文章:

html - Logo 和导航不在标题中居中

python - lxml:通过XSLT将XML转换为HTML并获取HtmlElements

html - CSS-如何防止显示原始标题信息

html - 页面布局两个并排的 div : right scrollable only, 左侧可扩展以适应内容

css - 使用CSS填充整个浏览器

html - css/html 在一个 href 中左右对齐

html - 在 Bootstrap 中使用搜索选项进行选择

javascript - Greasemonkey 脚本将一个元素移动到另一个元素?

jquery - 如果没有进行任何更改,jQuery 是否会在 .css() 调用上重绘页面?

html - 2 个 div 的高度彼此不对齐