HTML + CSS实现图片3D旋转效果

学了CSS的动画,仿照着自己做了一个3D旋转的小动画。先看看图片

这里是截图的图片,看不出来动态效果,可以把CSS和HTML复制下来直接放在文本编辑器中进行图片路径的修改

然后把格式转变成 .html 的就好了

视频演示链接:

https://www.ixigua.com/6954580295748157987

下面是代码:


<!DOCTYPE html>

<html lang="en">



<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>3D旋转</title>

    <link rel="icon" href="./image/logo.png">

    <style>

        body {



            perspective: 1500px;

        }



        section {

            position: relative;

            width: 261px;

            height: 450px;

            margin: 100px auto;

            transform-style: preserve-3d;



            /* animation: name duration timing-function delay iteration-count direction fill-mode;   */

            animation: rotate 8s linear infinite;

            /* 图片路径 */

            background: url(image/dl.png)no-repeat;

            /* opacity: 0.9; */

        }



        @keyframes rotate {

            0% {

                transform: rotateY(0);

            }



            100% {

                transform: rotateY(360deg);

            }

        }



        section div {

            width: 100%;

            height: 100%;

            position: absolute;

            top: 0;

            left: 0;

            /* background: url(image/xw.png)no-repeat; */

            opacity: 0.7;

        }



        section div:nth-child(2n) {

            /* 这里是外层的旋转图片路径 */

            background: url(image/xw.png)no-repeat;

        }



        section div:nth-child(2n+1) {

            /* 这里是外层旋转的图片路径 */

            background: url(image/ts.png)no-repeat;

        }



        section div:nth-child(1) {

            /* 在z轴上移动200px */

            transform: translateZ(300px);



        }



        section div:nth-child(2) {

            /* 在y轴上旋转60度,然后在z轴上移动300像素,下面类似 */

            transform: rotateY(60deg) translateZ(300px);



        }



        section div:nth-child(3) {

            transform: rotateY(120deg) translateZ(300px);



        }



        section div:nth-child(4) {

            transform: rotateY(180deg) translateZ(300px);



        }



        section div:nth-child(5) {

            transform: rotateY(240deg) translateZ(300px);



        }



        section div:nth-child(6) {

            transform: rotateY(300deg) translateZ(300px);



        }

        audio{

            border: none;

            

        }

    </style>

</head>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值