html - 具有响应式网格的图像叠加

标签 html css twitter-bootstrap

我在尝试在响应式 Bootstrap 网格中使用图像覆盖时遇到了问题。当页面全屏显示时,一切看起来都很好,但是当它低于 980 宽度时,图像会从网格底部渗出,但随着页面变小,看起来会越来越好。我知道我可以为此使用媒体查询,但是否有我忽略的解决方案?

HTML:

<div class="row">
    <div class="col-md-6">
        <div class="col-md-12">
            <div class="content-section">
                 <h1>Placeholder</h1>

                <p>Placeholder</p>
            </div>
        </div>
        <div class="col-md-12">
            <div class="content-section">
                 <h1>Placeholder</h1>

                <p>Placeholder</p>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <div class="col-md-12">
                <div class="content-section">
                     <h1>Placeholder</h1>

                    <p>Placeholder</p>
                </div>
            </div>
            <div class="col-md-12">
                <div class="content-section">
                     <h1>Placeholder</h1>

                    <div class="image-overlay">
                        <img class="bottom img-responsive" src="http://placehold.it/932x468">
                    </div>
                    <p>PlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholderPlaceholderlaceholder</p>
                                                </div>
                </div>
            </div>
        </div>

CSS

.content-section {
    position: relative;
    background-color: #2c2c2c;
    padding: 20px;
    margin-bottom 20px;
}
.image-overlay {
    position: relative;
    margin: 0 auto;
    height: 320px;
}
#image-overlay img {
    position: absolute;
    left: 0;
    -webkit-transition: opacity 1s ease-in-out;
    -moz-transition: opacity 1s ease-in-out;
    -o-transition: opacity 1s ease-in-out;
    transition: opacity 1s ease-in-out;
}
#image-overlay img.top:hover {
    opacity: 0;
}

我在这里创建了一个 JSFiddle:https://jsfiddle.net/1f8cbm2y/

谢谢!

最佳答案

我认为这会给您带来平板电脑分辨率方面的问题。因此,在没有媒体查询的情况下,您可以为平板电脑使用 col-sm-*

这是 jsfiddle solution .

关于html - 具有响应式网格的图像叠加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30873900/

相关文章:

javascript - Bootstrap scrollspy 与 ng-show 不能很好地配合

html - Twitter 的 Bootstrap - 表单输入太薄

html - 带有粘性页眉的粘性页脚?

html - 在我的 div 中居中 ul

javascript - jQuery 在 div 内垂直滚动图像

javascript - 有没有办法向上滚动无状态组件?

javascript - 为 chrome 扩展注入(inject) CSS

javascript - jquery 加载的文件仍在缓存中

javascript - 包装列表项以创建嵌入列表

html - 悬停缩放行为在 span 标签内的 img 标签上无法正常工作