transform 旋转相册练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0px;
            margin: 0;
        }
        body{
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #1abc9c;
            /* overflow: hidden; */
        }

        article{
            /* border: orange solid 2px; */
            width: 400px;
            height: 400px;
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1;
        }
        article:hover main{
            transform:perspective(900px)  rotateY(360deg);
        }

        main{
            width: 200px;
            height: 200px;
            display: flex;
            /* border:  solid tomato 5px; */
            transform-style: preserve-3d;
            transform-origin: center center -200px;
            transform:perspective(900px);/*进行透视*/
            transition: 3s;
        }


        div{
            position: absolute;
            width: 200px;
            height: 200px;
            
        }
        div>img{
            height: 100%;
        }
        div:nth-child(1){
            transform-origin: center center -200px;/*开始点*/
            transform: rotateY(90deg);/*360/4平均分布*/
        }
        div:nth-child(2){
            transform-origin: center center -200px;
            transform: rotateY(180deg);
        }
        div:nth-child(3){
            transform-origin: center center -200px;
            transform: rotateY(270deg);
        }
        div:nth-child(4){
            transform-origin: center center -200px;
            transform: rotateY(360deg);
        }

    </style>
</head>
<body>
    <article>
        <main>
            <div><img src="https://13miki.cdn.bcebos.com/af%2F750.jpg" alt=""></div>
            <div><img src="https://13miki.cdn.bcebos.com/af%2F751.jpg" alt=""></div>
            <div><img src="https://13miki.cdn.bcebos.com/af%2F752.jpg" alt=""></div>
            <div><img src="https://13miki.cdn.bcebos.com/af%2F753.jpg" alt=""></div>
        </main>
    </article>
</body>
</html>

 

点赞

发表评论