用css做一个旋转的地球仪

html部分:

<body>
    <div class="hoder"></div>
    <div class="circle"></div>
    <div class="circle equator"></div>
    <div class="circle weft1"></div>
    <div class="circle weft2"></div>
    <div class="circle weft3"></div>
    <div class="circle weft3"></div>
    <div class="circle weft4"></div>
    <div class="hoder2"></div>
    <div class="bottom"></div>
    <div class="bottom2"></div>
</body>

球的部分是将div的边框置为圆形

将圆圈进行3D旋转,就得到一个选装的透视球

transform: rotateX(70deg) translateZ(70px);

这个是将圆圈平躺下,做成赤道的样子

其余的weft是纬线,通过3D的Y轴变换得到

然后再做静态的支架即可

运行结果如下:


源代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>努力做个地球仪</title>
    <style>
        body{
            background-color: black;
        }
        .circle{
            border-radius: 100%;
            height: 100px;
            width: 100px;
            left: 200px;
            top: 200px;
            position: absolute;
            border: 1px solid #394057;
            transform-style: preserve-3d;
        }
        .equator{
            top:260px;
            transform: rotateX(70deg) translateZ(70px)
        }
        .weft1{
            -webkit-animation-duration:10s;
            -webkit-animation-iteration-count: infinite;
            -webkit-animation-timing-function: linear;
            -webkit-animation-name:weft1;
        }
        .weft2{
            -webkit-animation-duration:10s;
            -webkit-animation-iteration-count: infinite;
            -webkit-animation-timing-function: linear;
            -webkit-animation-name:weft2;
        }
        .weft3{
            -webkit-animation-duration:10s;
            -webkit-animation-iteration-count: infinite;
            -webkit-animation-timing-function: linear;
            -webkit-animation-name:weft3;
        }
        .weft4{
            -webkit-animation-duration:10s;
            -webkit-animation-iteration-count: infinite;
            -webkit-animation-timing-function: linear;
            -webkit-animation-name:weft4;
        }
        .hoder{
            height: 159px;
            width: 100px;
            left: 150px;
            top: 180px;
            position: absolute;
            border-right:2px solid #394057 ;
        }
        .hoder2{
            border-radius: 100%;
            border-left:3px solid #394057 ;
            height: 140px;
            width: 140px;
            top:180px;
            left: 180px;
            position: absolute;
        }
        .bottom{
            height:100px;
            width: 100px;
            border-radius: 100%;
            left: 200px;
            top: 355px;
            position: absolute;
            transform-style: preserve-3d;
            transform: rotateX(70deg) translateZ(70px);
            z-index: -100;
            border:2px solid #394057 ;
        }
        .bottom2{
            height:10px;
            width: 10px;
            border-radius: 100%;
            left: 244px;
            top: 397px;
            position: absolute;
            transform-style: preserve-3d;
            transform: rotateX(70deg) translateZ(70px);
            z-index: -100;
            border:2px solid #394057 ;

        }
        @-webkit-keyframes weft1{
            from{
                -webkit-transform:rotateY(40deg);
            }
            to{
                -webkit-transform:rotateY(400deg);
            }
        }
        @-webkit-keyframes weft2{
            from{
                -webkit-transform:rotateY(80deg);
            }
            to{
                -webkit-transform:rotateY(440deg);
            }
        }
        @-webkit-keyframes weft3{
            from{
                -webkit-transform:rotateY(120deg);
            }
            to{
                -webkit-transform:rotateY(480deg);
            }
        }
        @-webkit-keyframes weft4{
            from{
                -webkit-transform:rotateY(160deg);
            }
            to{
                -webkit-transform:rotateY(520deg);
            }
        }
    </style>
</head>
<body>
    <div class="hoder"></div>
    <div class="circle"></div>
    <div class="circle equator"></div>
    <div class="circle weft1"></div>
    <div class="circle weft2"></div>
    <div class="circle weft3"></div>
    <div class="circle weft3"></div>
    <div class="circle weft4"></div>
    <div class="hoder2"></div>
    <div class="bottom"></div>
    <div class="bottom2"></div>
</body>
</html>
 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值