我有一个网页,我在其中使用 css 交叉淡入淡出动画在两个背景图像之间淡入淡出。现在,我需要在两个图像上方添加相同的内容(徽标和按钮)。但是,此内容仅对第一张图像可见,而对第二张图像不可见。这是我的代码:
索引.html
<div id="bgimg">
<div class="bgimg-container">
<div id="hero">
<div class="bgimg-container">
My content here
</div>
</div>
</div>
</div>
样式.css
#bgimg{
display: table;
background: url(../img/2.jpg);
width:100%;
height:100vh;
background-position: top center;
background-size: cover;
background-repeat: no-repeat;
}
#hero {
display: table;
width: 100%;
height: 100vh;
background: url(../img/1.jpg);
background-position: top center;
background-size: cover;
background-repeat: no-repeat;
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 7s;
animation-direction: alternate;
}
@keyframes cf3FadeInOut {
0% {opacity:1;}
45% {opacity:1;}
55% {opacity:0;}
100% {opacity:0;}
}
@media (min-width: 1024px) {
#hero, #bgimg {
background-attachment: fixed;
}
}
#hero .hero-logo {
margin: 20px;
}
#hero .hero-logo img {
max-width: 100%;
}
#hero .hero-container {
background: rgba(0, 0, 0, 0.8);
display: table-cell;
margin: 0;
padding: 0;
text-align: center;
vertical-align: middle;
}
#bgimg .bgimg-container {
background: rgba(0, 0, 0, 0.8);
display: table-cell;
margin: 0;
padding: 0;
text-align: center;
vertical-align: middle;
}
我已经筋疲力尽地试图弄清楚。新来的,请帮忙。