如何在3D轮播中隐藏远距离图像

时间:2019-07-08 10:20:45

标签: html css

我创建了3D轮播,并希望将远端图像隐藏在其他图像之后。

我尝试使用z-index,但是它们都在图像的后面或上面显示了轮播。

HTML

<section id="slideshow">
            <div class="entire-content">
                <div class="content-carrousel">
                    <figure class="shadow"><img src="https://i.imgur.com/gxi7mUS.jpg"/></figure>
                    <figure class="shadow"><img src="https://i.imgur.com/jvezYfs.jpg"/></figure>
                    <figure class="shadow"><img src="https://i.imgur.com/DruSF8L.jpg"/></figure>
                    <figure class="shadow"><img src="https://i.imgur.com/H3nOS9Q.jpg"/></figure>
                    <figure class="shadow"><img src="https://i.imgur.com/njOuWQP.jpg"/></figure>
                    <figure class="shadow"><img src="https://i.imgur.com/UZ4aFKC.jpg"/></figure>
        </div>
    </div>
</section>

CSS

* {
    margin: 0;
    padding: 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    background-image: url('https://i.imgur.com/UgflRNF.jpg');
}

#slideshow {
    margin: 0 auto;
    padding-top: 10%;
    height: 600px;
    width: 100%;
}

.slideshow-title {
    font-size: 62px;
    color: #fff;
    margin: 0 auto;
    text-align: center;
    margin-top: 25%;
    letter-spacing: 3px;
    font-weight: 300;
}

.sub-heading {
    padding-top: 50px;
    font-size: 18px;
}
.sub-heading-two {
    font-size: 15px;
}
.sub-heading-three {
    font-size: 13px;
}
.sub-heading-four {
    font-size: 11px;
}
.sub-heading-five {
    font-size: 9px;
}
.sub-heading-six {
    font-size: 7px;
}
.sub-heading-seven {
    font-size: 5px;
}
.sub-heading-eight {
    font-size: 3px;
}
.sub-heading-nine {
    font-size: 1px;
}

.entire-content {
    margin: auto;
    width: 300px;
    perspective: 1200px;
    position: relative;
    padding-top: 80px;
    z-index: 1;
}

.content-carrousel {
    width: 100%;
    position: absolute;
    float: right;
    animation: rotar 15s infinite linear;
    transform-style: preserve-3d;
}

.content-carrousel:hover {
    animation-play-state: paused;
    cursor: pointer;
}

.content-carrousel figure {
    width: 100%;
    height: 220px;
    border: 1px solid #3b444b;
    overflow: hidden;
    position: absolute;
}

.content-carrousel figure:nth-child(1){ transform: rotateY(0deg) translateZ(300px); }
.content-carrousel figure:nth-child(2) { transform: rotateY(60deg) translateZ(300px); }
.content-carrousel figure:nth-child(3) { transform: rotateY(120deg) translateZ(300px); }
.content-carrousel figure:nth-child(4) { transform: rotateY(180deg) translateZ(300px); }
.content-carrousel figure:nth-child(5) { transform: rotateY(240deg) translateZ(300px); }
.content-carrousel figure:nth-child(6) { transform: rotateY(300deg) translateZ(300px); }
.shadow {
    position: absolute;
    box-shadow: 0px 0px 20px 0px #000;
    border-radius: 1px;
}

.content-carrousel img {
    image-rendering: auto;
    transition: all 300ms;
    width: 100%;
    height: 100%;
}

.content-carrousel img:hover {
    transform: scale(1.2);
    transition: all 300ms;
}

@keyframes rotar {
    from {
        transform: rotateY(0deg);
    }
    to {
        transform: rotateY(360deg);
        z-index: 2;
    }
}

我希望轮播的远图像位于中心图像的后面 我有jsfiddle https://jsfiddle.net/m_studio/y8phLf23/3/ (希望这是对的,这是我第一次做)

0 个答案:

没有答案