【发布时间】:2023-04-01 18:13:01
【问题描述】:
我有一个名为 my-app 的元素,它的 body 和 html 都设置为 100%。
在my-app 内部,我有另一个名为background-section 的元素,它的主体和html 设置为100%。在这个元素中,我有一个带有背景图像的部分。我希望这个背景图片是全屏的。
<section class="background-section">
<!-- this is another element -->
<nav-bar></nav-bar>
<div class="opening-msg">
<div class="app-container">
<h1>Find a perfect <br /> property</h1>
<span class="caption">
Connecting landlords & tenants through an easy to <br /> use web
application built for all devices
</span>
</div>
</div>
</section>
.background-section {
width: 100%;
background: linear-gradient( rgba(73, 77, 86, 0), rgb(73, 77, 86)), url('../../images/background-img2.jpg') no-repeat;
background-size: 100%;
box-sizing: border-box;
height: 100%;
}
问题是,由于某种原因,图像没有全屏显示。不知道为什么会这样。
【问题讨论】:
-
使用
background-size:cover -
@LokeshGupta 是的,我可以这样做,但我想要的是,当您访问该站点时,图像必须是全屏的,然后我向下滚动以查看页面的其他部分。
-
然后使用
Height:100vh;得到相同的结果。我根据您的需要发布了答案
标签: html css polymer custom-element polymer-2.x