HTML+CSS画个太阳

基础版

CSS:

html,body{
  margin: 0;
  padding: 0;
}
body{
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: gray;
}
.sun{
  width: 10em;
  height: 10em;
  /* 将正方形四直角改为圆角成 圆 */
  border-radius: 50%;
  /* 为太阳设置外围光辉阴影 */
  box-shadow: 0px 0px 100px #FFFF00;
  /* 为圆从外到内设置颜色 黄色-》红色 */
  background: radial-gradient(circle at center, red, gold);
}
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,我可以为您提供一些基本的代码示例来实现九大行星动画效果。以下是HTMLCSS代码示例: HTML代码: ```html <div class="container"> <div class="sun"></div> <div class="mercury"></div> <div class="venus"></div> <div class="earth"></div> <div class="mars"></div> <div class="jupiter"></div> <div class="saturn"></div> <div class="uranus"></div> <div class="neptune"></div> </div> ``` CSS代码: ```css .container { position: relative; width: 600px; height: 600px; margin: 0 auto; } .sun { position: absolute; top: 50%; left: 50%; margin-top: -50px; margin-left: -50px; width: 100px; height: 100px; border-radius: 50%; background-color: #FFCE00; animation: spin 10s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .mercury { position: absolute; top: 0; left: 50%; margin-left: -5px; width: 10px; height: 10px; border-radius: 50%; background-color: #C2B280; animation: orbit 2s linear infinite; } .venus { position: absolute; top: 0; left: 50%; margin-left: -15px; width: 30px; height: 30px; border-radius: 50%; background-color: #E6D6AD; animation: orbit 4s linear infinite; } .earth { position: absolute; top: 0; left: 50%; margin-left: -25px; width: 50px; height: 50px; border-radius: 50%; background-color: #3F4F5F; animation: orbit 6s linear infinite; } .mars { position: absolute; top: 0; left: 50%; margin-left: -35px; width: 70px; height: 70px; border-radius: 50%; background-color: #E45F56; animation: orbit 8s linear infinite; } .jupiter { position: absolute; top: 0; left: 50%; margin-left: -50px; width: 100px; height: 100px; border-radius: 50%; background-color: #E1B80D; animation: orbit 10s linear infinite; } .saturn { position: absolute; top: 0; left: 50%; margin-left: -65px; width: 130px; height: 130px; border-radius: 50%; background-color: #E1B80D; animation: orbit 12s linear infinite; } .uranus { position: absolute; top: 0; left: 50%; margin-left: -85px; width: 170px; height: 170px; border-radius: 50%; background-color: #9BC4E2; animation: orbit 14s linear infinite; } .neptune { position: absolute; top: 0; left: 50%; margin-left: -100px; width: 200px; height: 200px; border-radius: 50%; background-color: #6384B3; animation: orbit 16s linear infinite; } @keyframes orbit { from { transform: rotate(0deg) translate(150px) rotate(0deg); } to { transform: rotate(360deg) translate(150px) rotate(-360deg); } } ``` 以上代码将会在一个 600px x 600px 的容器内展示太阳系中的九大行星,每个行星都有自己的轨道和大小。太阳会以线性方式旋转,而行星则会沿着其轨道以相同的线性速度运动。请注意,上面的CSS代码中的动画效果仅适用于最新版本的现代浏览器,而在旧版浏览器中可能会有兼容性问题。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值