CSS3D动画制作一个3d旋转的筛子

希望这个demo能让大家理解CSS3的3d空间动画(其实是个假3D)

首先给一个3d的解剖图,x/y/z轴线轴线已经标出

1168666-20170519150909728-363955593.png

 

下面附上添加特效的动画旋转

可以根据demo并参考上面解剖图进行理解

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        html{
            height: 100%;
        }
        body{
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: black;
            perspective: 1000px;
            transform-style: preserve-3d;
            
        }
        section{
            width: 300px;
            height: 300px;
            transform-style: preserve-3d;
            animation: zhuan 16s infinite linear;
            
        }
        div{
            width: 300px;
            height: 300px;
            background-color: orange;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: center;
            position: absolute;   
            box-shadow: 0 0 300px green;
            opacity: 0.8;  
        }
        div:nth-child(1){
            transform: translateZ(300px);
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        div:nth-child(2){
            transform: rotateX(90deg) translateZ(300px);
            align-items: center;
            justify-content: space-around;
            flex-direction: column;
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        div:nth-child(3){
            transform: rotateY(90deg) translateZ(300px);
            flex-wrap: wrap;
            align-items: flex-start;
            justify-content: center;
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        div:nth-child(3) p:nth-child(2){
            align-self: center;
        }
        div:nth-child(3) p:nth-child(3){
            align-self: flex-end;
        }
        div:nth-child(4){
            transform: translateZ(-300px);
            flex-wrap: wrap;
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        div:nth-child(5){
            transform: rotateX(90deg) translateZ(-300px);
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        div:nth-child(6){
            transform: rotateY(90deg) translateZ(-300px);
            border-radius: 50%;
            box-shadow: 0 0 500px orange;
            opacity: 0.4;
        }
        .low{
            width: 300px;
            height: 150px;
            display: flex;
        }
        .low:nth-child(1){
            align-items: flex-end;
            justify-content: center; 
        }
        .low:nth-child(2){
            align-items: flex-start;
            justify-content: center;
        }
        .stree{
            width: 300px;
            height: 33.33%;
            display: flex;
        }
        .stree:nth-child(1){
            justify-content: space-around;
        }
        .stree:nth-child(2){
            justify-content: center;
        }
        .stree:nth-child(3){
            justify-content: space-around;
        }
        .fore{           
            width: 300px;
            height: 33.33%;
            display: flex;
        }
        .fore:nth-child(1){
            justify-content: center;
        }
        .fore:nth-child(3){
            justify-content: center;
        }
        p{
            width: 60px;
            height: 60px;
            background-color: white;
            border-radius: 50%;
            box-shadow: 200 60 400px #ccc;
            opacity: 0.7;
            margin: 10px;
            
        }
        @keyframes zhuan{
            0%{
                transform: rotateX(0deg) rotateY(0deg);
            }
            100%{
                transform: rotateX(360deg) rotateY(360deg) ;
            }
        }
      
    </style>
</head>
<body>  
    <section>
        <div>
            <p></p>
        </div>
        <div>
            <p></p>
            <p></p>
        </div>
        <div>
            <p></p>
            <p></p>
            <p></p>
        </div>
        <div>
        <main class="low">
            <p></p>
            <p></p>
        </main>
        <main class="low">    
            <p></p>
            <p></p>
        </main>
        </div>
        <div>
        <main class="stree">
            <p></p>
            <p></p>
        </main>
        <main class="stree">    
            <p></p>
        </main>
        <main class="stree">
            <p></p>
            <p></p>
        </main>
        </div>
        <div>
            <main class="fore">
            <p></p>
                <p></p>
            </main>
            <main class="stree">    
                <p></p>
                <p></p>
            </main>
            <main class="fore">
                <p></p>
                <p></p>
            </main>
        </div>      
    </section>
</body>
</html>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值