css - 水平布局问题 - div 重叠

标签 css nowrap

我遇到水平布局问题:http://jsfiddle.net/GqH6s/4/

父 #content div 的宽度似乎是从其第一个子项 (#projects) 获取的,而不是其所有子项的总和。

我知道我可以使用 jQuery 来解决这个问题,但如果可能的话我想使用 CSS。

感谢您的帮助!

基本的 html:

<div id="content">
    <div id="projects" class="section">
        <div class="block">Content</div>
    </div>
    <div id="profile" class="section">
        <div class="block">Content</div>
    </div>
    <div id="team" class="section">
        <div class="block">Content</div>
    </div>
</div>

和 CSS:

    #content {
        white-space: nowrap;
        display: inline-block;
    }
    .section {
        display: inline-block;
    }
    .block {
        white-space: normal;
    }

最佳答案

您需要将#profile 和#team div 放在#project div 中,以便它们与其余部分内嵌显示。

应该看起来像这样:

enter image description here

enter image description here

关于css - 水平布局问题 - div 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20053289/

相关文章:

javascript - 将一个 div 滑出屏幕(边距为 : 0px auto)

css - 悬停在第 n 个 child 身上

whitespace - 根据其子宽度扩展一个 div 宽度

css 空白 :nowrap horizontal scroll bug

css - 当 ul 具有 nowrap 属性时,如何让 ul 通过窗口宽度改变来调整大小

html - 仅当滚动到底部时才将页脚固定到底部

css - Flexbox:带有列换行的可变/动态高度元素

html - 嵌套空白 : normal; inside parent of white-space: nowrap; - Parent no longer has correct width 的 CSS 问题

CSS 布局问题