【发布时间】:2020-09-25 21:41:57
【问题描述】:
我有一个通过 CSS 设计的带有背景图片的主页。但是,当页面加载左侧的一部分而右侧的一部分保持白色时。我想让它适合屏幕。
这是我的 HTML :
<header>
<section class="bg">
<div [style.color]="'white'">
<h1> Welcome to Shopping Cart</h1>
<h2> Online grocery purchase made easy.</h2>
</div>
</section>
</header>
这是我的 CSS
.bg{
background-image: url('/assets/images/shopping-1.jpg');
height: 100vh;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
/*background-size: contain;*/
/*background-color: darkblue;*/
}
我尝试过使用width:100vw,但它不起作用。右边越来越伸展,左边仍然是空白的白色部分。设置width: 84vw; 使其在右侧正确。但是左边还是空白。我无法将背景图像向左移动。如何使整个背景图像适合屏幕。
首页图片:
【问题讨论】:
标签: javascript html css angular