简单2d动画 , 仿太阳绕地球旋转

body 部分

 <div class="universe">
	<div class="sun">
		<div class="earth">
		</div>
	</div>
 </div>

style 部分

<style media="screen">

        .universe {
          margin: 0 auto;
          margin-top: 100px;
          height: 200px;
          width: 200px;
          border-radius: 50%;
          border: 1px solid transparent;
          position: relative;
          animation: circle 3s ease infinite
        }
        .sun {
          height: 100px;
          width: 100px;
          border-radius: 50%;
          left: 50%;
          top: 50%;
          margin-top: -50px;
          margin-left: -50px;
          background: radial-gradient(red, yellow, #f09635);
          position: absolute;
        }
        .earth {
          height: 20px;
          width: 20px;
          border-radius: 50%;
          left: -60px;
          top: 40px;
          background: radial-gradient(blue, #00c1ff, green);
          position: absolute;
        }

        @keyframes circle {
          from {
            transform: rotate(0);
          }
          to {
            transform: rotate(360deg);
          }
        }
</style>

思路 , 外围设定一个祖父级div , 位置相对定位; sun 与 earth 绝对定位 , 位置固定 , earth在祖父border线上 。 只需旋转祖父级div , 那么效果看起来就像earth在旋转一样

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值