html - Bootstrap CSS/HTML 背景图像调整大小

标签 html css twitter-bootstrap twitter-bootstrap-3 background-image

当我调整浏览器大小时使用 Bootstrap ,背景中的图片会缩小,而背景颜色不会缩小。

以下是包含 HTML 代码的网站链接:http://codedifferently.com/crest.html

这是我使用的 CSS 代码:

@charset "UTF-8";

/* CSS Document */


/* Move down content because we have a fixed navbar that is 50px tall */

body {
  padding-top: 0px;
  padding-bottom: 20px;
}

div.jumbotron {
  background-image: url('img/chicago2.jpg');
  background-color: #3FF;
  background-size: 100%;
  height: 500px;
  background-repeat: no-repeat;
  background-position: center center;
  background-attachment: fixed;
}

div.navbar navbar-default navbar-static-top" role="navigation {
  border: 0px;
}

最佳答案

如果我理解正确,不确定,因为背景颜色确实缩小,但我认为你的意思是你的图像应该调整大小并且颜色应该不像现在处于全 View 状态。所以如果理解正确的话。

更改此:

background-size: 100%;

background-size: cover;

并添加浏览器的供应商以使其跨浏览器:

-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;

查看有关 background-size的更多信息

关于html - Bootstrap CSS/HTML 背景图像调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26198333/

相关文章:

twitter-bootstrap - 如何让Bootstrap的导航下拉菜单顺滑上下滑动?

html - 使用 CSS 添加虚线间隔器/填充

java - 内联实例类作为枚举中的参数

php - 如何使用 JavaScript 验证动态生成的输入框

javascript - Webworks 中的 Blackberry 固定页眉和页脚

html - 这两个类有什么区别

css - Bootstrap CSS 设计 div 框 - 居中问题

css - 悬停时扩展文本

javascript - 我无法使粘性标题工作

javascript - 在移动浏览器中使用 jquery 的位置