Bootstrap-全屏幕背景照片/图像

时间:2016-01-26 16:31:37

标签: css twitter-bootstrap

我正在使用Bootstrap 3.3.6封面模板(http://getbootstrap.com/examples/cover/)构建登录页面。我正在尝试添加全屏背景图像。我相信问题可能是我没有div class =" cover"在我的HTML代码中。我的css代码如下:

.cover {
  padding: 0 20px;
}

提前谢谢你。

1 个答案:

答案 0 :(得分:2)

正确的是,要创建此项,请body width height 100%

body {
    width: 100%;
    height: 100%;
}

然后你需要有一个元素来应用背景,就像header

一样
<header> 
    <div class="content">
    </div>
</header>

然后将标题设为background-image

header {
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url(../img/BG.png);
  background-repeat: no-repeat;
  background-size: cover;
  display: block;
}

您不必使用标题来创建自己的类,例如名为.full-sceen-bg并将其应用于任何部分

希望这会有所帮助,任何问题都可以问

相关问题