我在这里陷入困境,试图弄清楚如何让背景图像在下面的DIV下面下垂。我不得不采取一些相当不好的手段。在DIV中包含背景图像的CSS
.animation span {
position: absolute;
top: 0;
width: 100%;
height: 100%;
z-index: -999;
animation-name: fade;
animation-iteration-count: infinite;
animation-duration: 40s;
background-size: cover cover;
background-repeat: no-repeat;
background-position: center center;
}
...
<body>
<div id='banner'>
<div class="animation">
<span id="f4"></span>
<span id="f3"></span>
<span id="f2"></span>
<span id="f1"></span>
</div>
<div id="title">
<h1>Silly Webpage Banner</h1>
</div>
</div>
<div id="content" style="background-color:white;">
Content
</div>
</body>
我不得不增加高度,宽度,顶部动画类刚好能看到图像。如果我排除z-index,则内容DIV将沉入一层。我真的很喜欢它来尊重背景大小和背景位置,但我不明白为什么它不会。
真厉害!搞定了!我只将'height:4rem'更改为'height:auto',以便在横幅标题封装时正确响应。谢谢!!! – MrCleanX