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

html5圖片3d疊加幻燈片切換代碼

錢多多2年前9瀏覽0評論

HTML5圖片3D疊加幻燈片切換效果能夠為網(wǎng)站注入獨特的視覺效果,提升用戶體驗度。接下來,我們將為大家介紹這一功能對應(yīng)的代碼實現(xiàn)方法。

// HTML 代碼段
<div class="slider">
<div class="slider-item i1 active">
<img src="img/1.jpg" alt="Image 1" />
<div class="caption">
<h2>標(biāo)題1</h2>
<p>內(nèi)容1</p>
</div>
</div>
<div class="slider-item i2">
<img src="img/2.jpg" alt="Image 2" />
<div class="caption">
<h2>標(biāo)題2</h2>
<p>內(nèi)容2</p>
</div>
</div>
<div class="slider-item i3">
<img src="img/3.jpg" alt="Image 3" />
<div class="caption">
<h2>標(biāo)題3</h2>
<p>內(nèi)容3</p>
</div>
</div>
<div class="slider-item i4">
<img src="img/4.jpg" alt="Image 4" />
<div class="caption">
<h2>標(biāo)題4</h2>
<p>內(nèi)容4</p>
</div>
</div>
</div>

CSS 代碼段:

/* 公共樣式 */
.slider {
position: relative;
}
.slider-item {
position: absolute;
opacity: 0;
-webkit-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
-webkit-transform: translateZ(-100px);
transform: translateZ(-100px);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.slider-item.active {
opacity: 1;
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.slider-item img {
width: 100%;
height: auto;
display: block;
}
.caption {
position: absolute;
bottom: 0;
right: 0;
padding: 20px;
margin: 0;
color: #fff;
text-align: right;
background-color: rgba(0, 0, 0, 0.5);
box-sizing: border-box;
}
/* 單獨樣式 */
.slider-item.i1 {
-webkit-transform: rotateY(0deg) translateZ(0);
transform: rotateY(0deg) translateZ(0);
}
.slider-item.i2 {
-webkit-transform: rotateY(-90deg) translateZ(-200px);
transform: rotateY(-90deg) translateZ(-200px);
}
.slider-item.i3 {
-webkit-transform: rotateY(-180deg) translateZ(-200px);
transform: rotateY(-180deg) translateZ(-200px);
}
.slider-item.i4 {
-webkit-transform: rotateY(-270deg) translateZ(-200px);
transform: rotateY(-270deg) translateZ(-200px);
}
.slider-item.active.i1,
.slider-item.active.i2,
.slider-item.active.i3,
.slider-item.active.i4 {
z-index: 1;
-webkit-transform: rotateY(0deg) translateZ(0);
transform: rotateY(0deg) translateZ(0);
}

JS 代碼段:

var active = 1;
var numItems = $('.slider-item').length;
setInterval(function() {
$('.slider-item.i' + active).removeClass('active');
active++;
if (active >numItems) {
active = 1;
}
$('.slider-item.i' + active).addClass('active');
}, 5000);

以上就是HTML5圖片3D疊加幻燈片切換的所有代碼實現(xiàn),讀者可以根據(jù)項目需求進(jìn)行適當(dāng)調(diào)整。