html - 为什么父 div 宽度不拉伸(stretch)到子宽度

标签 html css twitter-bootstrap

看看这个 jsfiddle:

http://jsfiddle.net/w9k2sz52/

#content {
    background: #ff0000;
    min-height: 200px;
}
.container-fluid {
    min-width: 2000px;
}

<div id="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-xs-12">
                <h1>Some title here</h1>
            </div>
        </div>
    </div>
</div>

为什么#content 的宽度没有拉伸(stretch)为 2000px 而不是视口(viewport)的宽度?我需要做什么才能使内容拉伸(stretch),以便无论在 container-fluid 上设置什么最小宽度#content 总是会拉伸(stretch)以适应它

最佳答案

#content设置为inline-block,然后将min-width设置为100%。请注意,将 width 设置为 100% 不会产生预期的效果。

#content {
    background: #ff0000;
    min-height: 200px;
    min-width: 100%;
    display:inline-block;
}

关于html - 为什么父 div 宽度不拉伸(stretch)到子宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28632828/

相关文章:

css - 如何格式化 Bootstrap 表单标签以匹配表单输入的宽度?

html - CSS 填充仅在元素 float 时才能正确显示

html - 在 Safari 中使用 location.hash 滚动页面

css - DIV/表格对齐

html - 使用 Razor/Sitecore 编辑 CSS

javascript - 如何获取表内 TouchSpin 的值

javascript - 使用 jscript 跟踪对网页字段所做的更改?

html - CSS 溢出/z-index 问题 - 标记未在 SAFARI 中显示

css - 平板电脑上的 Bootstrap 3 网格布局问题

html - 如何居中让四张图片彼此居中(Bootstrap)