【发布时间】:2019-06-29 18:31:23
【问题描述】:
我正在尝试创建一个登陆页面,我计划将一些固定的背景图像定位为固定在顶部的幻灯片,然后是另一个 div,其中包含网站的内容。然而,当前的 HTML 和 CSS 代码将两个 div 放在一起。
在检查现有代码并使用 position 属性并将父 div 设置为相对位置而将子 div 设置为相对位置时也不起作用
.crossfade>figure {
animation: imageAnimation 30s linear infinite 0s;
backface-visibility: hidden;
background-size: cover;
background-position: center;
color: transparent;
height: 100%;
left: 0px;
opacity: 0;
position: absolute;
top: 0px;
bottom: 0;
width: 100%;
z-index: -1;
min-height: 700px;
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
}
#landing {
position: absolute;
top: 500px;
}
<div className="main">
<div class="crossfade">
<figure></figure>
<figure></figure>
</div>
<div id="landing">
<div className="container">
<img />
</div>
<p> Hello </p>
</div>
</div>
预期的 css 应该是一个接一个地放置两个 div,同时保留顶部背景图像幻灯片,然后显示第二个 div。
【问题讨论】: