微信小程序--行星轨迹

海轰Pro

共 2857字,需浏览 6分钟

 · 2021-03-10

行星轨迹

效果展示

Demo代码

index.wxml

<view id="container">
 <view id="sun"></view>
 <view class="orbit" id="earth-orbit">
  <view class="globe" id="earth">
   <view class="orbit" id="moon-orbit">
    <view class="globe" id="moon"></view>
   </view>
  </view>
 </view>
</view>

index.wxss

page {
  background-color#20202c;
  height100vh;
}

#container {
  height400px;
  leftcalc(50% - 200px);
  position: absolute;
  topcalc(50% - 200px);
  width400px;
}

#container #sun {
  background-color: yellow;
  border-radius50%;
  box-shadow0 0 30px white;
  height100px;
  left150px;
  position: absolute;
  top150px;
  width100px;
}

#container .orbit {
  border: solid;
  border-color: white transparent transparent transparent;
  border-radius50%;
  border-width1px 1px 0 0;
  box-sizing: border-box;
  position: absolute;
  transformrotate(0deg);
  transform-origin: center;
}

#container .orbit#earth-orbit {
  animation: orbit 6s linear infinite;
  height300px;
  left50px;
  top50px;
  width300px;
}

#container .orbit#moon-orbit {
  animation: orbit 2.7s linear infinite;
  height80px;
  left: -25px;
  top: -25px;
  width80px;
}

#container .orbit .globe {
  border-radius50%;
  position: absolute;
}

#container .orbit .globe#earth {
  background: aqua;
  height30px;
  right28px;
  top28px;
  width30px;
}

#container .orbit .globe#moon {
  background#d6d6d6;
  height12px;
  right2px;
  top8px;
  width12px;
}

@-webkit-keyframes orbit {
  to {
    transformrotate(360deg);
  }
}

@keyframes orbit {
  to {
    transformrotate(360deg);
  }
}

说明

1.学习于网络

2.Demo已同步至小程序:海轰Pro

写留言|查看留言

浏览 31
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报