如何在CSS中制作背景图像?

时间:2017-09-04 19:00:47

标签: css css3 background-image fullscreen

我的背景图片覆盖了屏幕上方100%的屏幕。背景图片的HTML和CSS是:



.mb {
  background-image: url(../assets/img/Uploads/xyz.jpg);
  background-repeat: no-repeat;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  background-size: 100% 100%;
  justify-content: center;
}

<div class="mb">
</div>
&#13;
&#13;
&#13;

我想知道我需要在CSS中进行哪些更改,以便它应覆盖屏幕上方60-70%的屏幕。我尝试调整图像大小,但仍然无法覆盖70-80%的屏幕。

1 个答案:

答案 0 :(得分:0)

.mb {
  background-image: url(../assets/img/Uploads/xyz.jpg);
  background-repeat: no-repeat;
  height: 70vh;
  width: 100%;
  background-size: 100% 100%;
  position: absolute;
  top: 0;
  left: 0;
}