gpt4 book ai didi

html - 使用 CSS3 的水平幻灯片

转载 作者:行者123 更新时间:2023-11-28 00:58:01 25 4
gpt4 key购买 nike

<分区>

所以我知道那里有很多水平幻灯片,但我一直试图跟随它们,每次出现问题时。每次它要么真的很复杂,要么对我来说根本不起作用。所以我尝试创建自己的(抱歉代码困惑):

.wrapper {
width: 100%;
height: 35vw;
margin: auto;
background: #fff url("https://s-media-cache-ak0.pinimg.com/originals/a4/f2/cb/a4f2cb80ff2ae2772e80bf30e9d78d4c.gif") no-repeat center;
background-size: 200px 200px;
}

.slides {
position: absolute;
height: 35vw;
width: 100%;
}

#slide1{
background: transparent url("https://www.planwallpaper.com/static/images/hd-wallpaper-1080p-widescreen-1080p-backgrounds.jpg") no-repeat center;
background-size: cover;
animation: left1 15s infinite;
}

#slide2 {
background: transparent url("https://www.planwallpaper.com/static/images/hd-beach-wallpapers-1080p.jpg") no-repeat center;
background-size: cover;
animation: left2 15s infinite;
left: 100%;

}
#slide3 {
background: transparent url("https://www.planwallpaper.com/static/images/01819_birdonabranch_1920x1080.jpg") no-repeat center;
background-size: cover;
animation: left3 15s infinite;
left: 200%;
}

@keyframes left1 {
0% {left: 0%; right:0%;}
26.8% {left: 0%; right:0%;}
33.5% {left: -100%; right: 100%;}
93.8% {left: -200%; right: 200%;}
100% {left: 0%; right: 0%;}
}

@keyframes left2 {
0% {left: 100%; right:-100%;}
26.8% {left: 100%; right:-100%;}
33.5% {left: 0%; right: 0%;}
60.3% {left: 0%; right: 0%;}
67% {left: -100%; right: 100%;}
93.8% {left: -100%; right: 100%;}
100% {left: 100%; right: -100%;}
}

@keyframes left3 {
0% {left: 200%; right:-200%;}
26.8% {left: 200%; right:-200%;}
33.5% {left: 100%; right: -100%;}
60.3% {left: 100%; right: -100%;}
67% {left: 0%; right: 0%;}
93.8% {left: 0%; right: 0%;}
100% {left: 200%; right: -200%;}
}
<body>

<div class="wrapper">
<div class="slides" id="slide1"></div>
<div class="slides" id="slide2"></div>
<div class="slides" id="slide3"></div>
</div>
</body>

起初,我以为我没事。然后我注意到您可以水平滚动。我尝试通过以不同方式使用 overflow:hidden 以及与 display: 和 position: 的组合来解决这个问题。什么都不管用。要么图像定位不正确,要么动画不工作。我从没想过在页面外定位元素会如此困难。
附言我没有学过任何网页设计,我是自学成才并尝试创建一个像样的网站。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com