WEB前端程序开发程序员

长方体3D轮播图(CSS3实现)

2017-03-02  本文已影响886人  ForeverYoung20

效果图:

1.png 2.png

注意点:

代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style>
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 200px;
            height: 200px;
            margin: 150px auto;
            perspective: 500px;
        }
        ul{
            width: 200px;
            height: 200px;
            box-sizing: border-box;
            position: relative;
            transform-style: preserve-3d;
            animation:move 4s linear 0s infinite normal;
        }
        @keyframes move {
            from{
                transform: rotateX(0deg);
            }
            to{
                transform: rotateX(360deg);
            }
        }
        ul li{
            width: 200px;
            height: 200px;
            line-height: 200px;
            text-align: center;
            font-size: 28px;
            list-style: none;
            position: absolute;
            top: 0;
            left: 0;
        }
        ul li:nth-child(1){
            background: red;
            transform:rotateX(90deg) translateZ(100px) scale(2,1);
        }
        ul li:nth-child(2){
            background: green;
            transform: rotateX(180deg) translateZ(100px) scale(2,1);
        }
        ul li:nth-child(3){
            background: blue;
            transform: rotateX(270deg) translateZ(100px) scale(2,1);
        }
        ul li:nth-child(4){
            background: yellow;
            transform:  rotateX(360deg) translateZ(100px) scale(2,1);
        }
    </style>
</head>
<body>
<div>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
</div>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读