色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

css實現無縫滑動

李中冰1年前12瀏覽0評論

CSS實現無縫滑動,通常使用CSS3的transition屬性和transform屬性,可以使頁面中的元素滑動起來,而且動畫效果非常流暢,下面是一些實現無縫滑動的CSS代碼。

.slider {
width: 500px;
height: 250px;
overflow: hidden;
}
.slider .slides {
display: flex;
width: 500%;
height: 100%;
}
.slider .slides .slide {
width: 20%;
height: 100%;
}
.slider .slides .slide:first-child {
margin-left: 0;
}
.slider .slides .slide:last-child {
margin-right: 0;
}
.slider .slides .slide:nth-child(1) {
background-image: url(img/slide1.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.slider .slides .slide:nth-child(2) {
background-image: url(img/slide2.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.slider .slides .slide:nth-child(3) {
background-image: url(img/slide3.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.slider .slides .slide:nth-child(4) {
background-image: url(img/slide4.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.slider .slides .slide:nth-child(5) {
background-image: url(img/slide5.jpg);
background-size: cover;
background-repeat: no-repeat;
}
.slider .slides .slide:nth-child(n) {
transition: 1s;
transform: translateX(0);
}
.slider .slides .slide.active {
transform: translateX(-20%);
}
.slider .slides .slide.active + .slide {
transform: translateX(-40%);
}
.slider .slides .slide.active + .slide + .slide {
transform: translateX(-60%);
}
.slider .slides .slide.active + .slide + .slide + .slide {
transform: translateX(-80%);
}
.slider .navigation {
display: flex;
justify-content: center;
margin-top: 5px;
}
.slider .navigation .indicator {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #fff;
margin: 0 5px;
cursor: pointer;
}
.slider .navigation .indicator.active {
background-color: #ff4500;
}

以上是實現無縫滑動的CSS代碼,通過使用transition屬性和transform屬性,可以制作出非常流暢的滑動效果,同時可以結合JavaScript實現自動播放和手動滑動的功能。