【发布时间】:2020-09-24 02:41:45
【问题描述】:
我的着陆页上有两张图片,它们使用默认的淡入淡出动画来回切换。我的第一个问题是我想使用滑动动画,但我没有找到任何更改它的选项。我的第二个问题是淡入淡出动画仅适用于 chrome。有没有办法在其他浏览器中解决这个问题?
我的代码:
/* basicStyle.css */
* {
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 100%;
}
.lead {
font-size: 1.5rem;
}
.navbar {
position: fixed;
top: 0;
z-index: 1;
display: flex;
width: 100%;
height: 60px;
background: rgba(0, 0, 0, 0.7);
}
.navbar ul {
display: flex;
list-style: none;
width: 100%;
justify-content: center;
}
.navbar ul li {
margin: 0 1rem;
padding: 1rem;
}
.navbar ul li a {
text-decoration: none;
text-transform: uppercase;
color: #f4f4f4;
}
.navbar ul li a:hover {
color: skyblue;
}
section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
width: 100%;
}
section h1 {
font-size: 4rem;
}
/* Section Images */
section#home {
background: black;
min-height: 100vh;
}
section#gallery {
background: red;
min-height: 100vh;
}
section#about {
background: green;
min-height: 100vh;
}
section#contact {
background: blue;
min-height: 100vh;
}
/* LandingPage.css */
* {
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
font-family: 'Montserrat';
font-size: 17px;
color: #fff;
line-height: 1.6;
}
#showcase {
background: url('https://images.unsplash.com/photo-1597368208802-2bec16fba411?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1051&q=80')
100vw 0 no-repeat,
url('https://images.unsplash.com/photo-1597390520089-9f46046ea040?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1041&q=80')
0 0 no-repeat;
background-size: cover;
background-position: center;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
padding: 0 20px;
animation: slide-right 15s forwards 2s infinite;
}
@keyframes slide-right {
0% {
background-position: 100vw 0, 0 0;
}
50% {
background-position: 0vw 0, 0 0;
}
100% {
background-position: 100vw 0, 0 0;
}
}
#showcase h1 {
font-size: 50px;
line-height: 1.2;
}
#showcase p {
font-size: 20px;
color: #fff;
}
#showcase .button {
font-size: 18px;
text-decoration: none;
color: #fff;
border: #fff 1px solid;
padding: 10px 20px;
border-radius: 10px;
margin-top: 20px;
}
.main-section div.iScrollIndicator {
background: white !important;
}
.navbar {
position: fixed;
top: 0;
z-index: 1;
display: flex;
width: 100%;
height: 70px;
background: rgba(57, 77, 95, 0.7);
z-index: 2;
}
.navbar ul {
display: flex;
list-style: none;
width: 100%;
justify-content: center;
}
.navbar ul li {
margin: 10px;
padding: 5px;
}
.navbar ul li a {
text-decoration: none;
text-transform: uppercase;
color: #f4f4f4;
font-size: 30px;
}
.buttons {
display: flex;
justify-content: center;
}
.buttons .button {
margin: 10px;
display: grid;
place-items: center;
}
<div class="container">
<!-- <nav class="navbar">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#service">Service</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav> -->
<header id="showcase">
<h1>Welcome!</h1>
<div class="buttons">
<a href="#about" class="button"><span>About</span></a>
<a href="#gallery" class="button"><span>Gallery</span></a>
</div>
</header>
<section id="about">
<h1>About</h1>
</section>
<section id="gallery">
<h1>Gallery</h1>
</section>
<section id="contact">
<h1>Contact</h1>
</section>
</div>
【问题讨论】:
-
您想用幻灯片动画替换淡入淡出动画吗?还是页面的其他部分?
-
是的,我想用幻灯片动画替换淡入淡出动画
-
我想获得一个非常相似的结果。唯一的区别是我的图片是全屏图片,上面有一些文字...link
-
其他浏览器应该可以工作,除非你指的是 IE
标签: html css background css-animations