如何在div上创建响应背景

问题描述 投票:0回答:1

我正在尝试在div元素上制作响应式背景图像,但是它不起作用。

这是我的CSS:

.block-main{
  background: url(images/ohdaihiep/bg1.png) center center/cover no-repeat;
  min-height:863px;
}
css bootstrap-4 responsive-design background responsive-images
1个回答
0
投票

您可以使用vhvw使其具有响应性:

fiddle玩。

.block-main {
  background: url(http://placekitten.com/301/301)center center/cover no-repeat;
  height: 100vh;
  width: 100vw;
}
<div class="block-main">

</div>
© www.soinside.com 2019 - 2024. All rights reserved.