美文网首页
css 列表元素显示3d效果

css 列表元素显示3d效果

作者: sunxiaochuan | 来源:发表于2023-05-15 16:52 被阅读0次

    效果

    image.png

    代码

    <!DOCTYPE html>
    <html>
        <head>
            <title>3D凹陷效果示例</title>
            <style type="text/css">
                .list {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    list-style: none;
                    margin: 0;
                    padding: 0;
                    /* box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); */
                    transform-style: preserve-3d;
                    perspective: 100vw;
                }
    
                .list li {
                    width: 200px;
                    height: 100px;
                    margin: 10px;
                    text-align: center;
                    font-size: 24px;
                    font-weight: bold;
                    background-color: #ccc;
                    transition: all 0.5s ease-in-out;
                    transform-origin: left center;
                    z-index: 1;
                    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8) inset;
                }
    
                .list li:nth-child(1) {
                    transform: rotateY(30deg);
                }
                .list li:nth-child(2) {
                    transform: rotateY(30deg);
                }
    
                .list li:nth-child(4) {
                    transform: rotateY(-30deg);
                    transform-origin: right center;
                }
    
                .list li:nth-child(5) {
                    transform: rotateY(-30deg);
                    transform-origin: right center;
                }
                .list li:hover {
                    transform-origin: center center;
                    transform: rotateY(0) scale(1.1);
                }
            </style>
        </head>
        <body>
            <ul class="list">
                <li>列表项1</li>
                <li>列表项2</li>
                <li>列表项3</li>
                <li>列表项4</li>
                <li>列表项5</li>
            </ul>
        </body>
    </html>
    
    

    相关文章

      网友评论

          本文标题:css 列表元素显示3d效果

          本文链接:https://www.haomeiwen.com/subject/evzmsdtx.html