html - 使用 bootstrap/css 根据屏幕大小更改背景图像的高度

标签 html css twitter-bootstrap

我有一个页面,我在其中使用 bootstrap 进行设计。现在我正在使用网格;我想为图像保留 8 列,为文本保留 4 列。所以我有以下代码:-

<div class="container-fluid">
    <div class="row">
        <div class="col-md-8">
            <div class="bg"></div>
        </div>
        <div class="col-md-4">
            hi how are you
        </div>
    </div>
</div>

以下是类 bg 的 css:

.bg {
    background-image: url('../images/2.jpg');
    background-repeat: no-repeat;
    background-position: center center;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    height:690px;
}

现在一切正常,但我在这里遇到一个小问题,我在超小屏幕上检查它,图片几乎占据了整个屏幕,对于文本我必须滚动到底部。

有没有什么方法可以调整超小屏幕的图像高度(宽度效果很好),这样图像和文本就可以一起看到而无需太多滚动?

最佳答案

尝试在 CSS3 中使用视口(viewport)高度:

.bg {
    height:100vh;
}

关于html - 使用 bootstrap/css 根据屏幕大小更改背景图像的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35475928/

相关文章:

python - 如果 django 上的其他表中已存在 ID,如何禁用或隐藏分配/重定向按钮

javascript - 在页面加载时显示固定列,当用户单击符号时显示 html 表中的剩余列

html - Powershell 通过管道将字符串数组传递给 ConvertTo-Html

html - 将 CSS 链接到 HTML 时遇到问题

html - 如何使 Bootstrap 粘性页脚内容达到整页高度?

html - 基于 Bootstrap 的页面底部有很多空白区域,页脚显示不正确

html - 一行中的 Span 元素不会在 Chrome 浏览器中的 Bootstrap 容器中换行

javascript - 处理时的 jQuery 数据表和动画 SVG

javascript - 我的滑出菜单可以在 HTML 中运行,但不能在 PHP 中运行

asp.net-mvc-4 - Nuget 外部包不能依赖于目标项目的包