纯CSS3打造自行车动画效果(代码实例)

本文通过代码实例详细讲解如何使用纯CSS3创建自行车动画效果。包含关键代码展示,并分享了学习前端开发的经验与注意事项,适合初学者和进阶者参考。同时提供了交流群号,以供前端学习者共同进步。
摘要由CSDN通过智能技术生成

纯CSS3如何打造自行车动画效果?下面本篇文章通过代码实例给大家介绍一下。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

我们先来看看效果图吧,看了效果图之后你们就会有动力去打造属于你们自己的自行车啦

代码如下,复制即可用

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>快来打造属于你们自己的自行车吧</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0
}

ol,
ul {
  list-style: none/*去掉圆点或数字*/
}

.cycle-outer {
  width: 534px;
  height: 260px;
  position: absolute;
  /*绝对定位*/
  top: 50%;
  /*距离顶部*/
  margin: -160px 0 0 -267px;
  /*距离外边距*/
  left: 50%;
}

.cycle-wrapper {
  width: 534px;
  height: 260px;
  margin: 0 auto;
  position: relative;
  /*相对定位*/
}

.cycle-wheel-front {
  /*前轮*/
  margin: 100px 0 0 330px;
}

.cycle-wheel-back {
  /*后轮*/
  margin: 100px 0 0 0px;
}

.cycle-wheel-outer {
  background: transparent;
  border: 5px solid #aaa;
  border-radius: 50%;
  /*画外轮圆圈*/
  width: 190px;
  height: 190px;
  position: absolute;
  margin-top: 5px;
  animation: wheel-rotate 2s linear infinite;
  /*定义动画*/
}
/*轮胎开始旋转*/
@keyframes wheel-rotate {
  from {
      transform: rotate(0deg);
  }
  to {
      transform: rotate(360deg);
  }
}

.cycle-wheel-outer:after {
  /*插入内轮胎圆圈*/
  background: transparent;
  border: 4px solid #EF9058;
  border-radius: 50%;
  width: 176px;
  height: 176px;
  position: absolute;
  margin: 3px;
  content: "";
}

.spoke {
  /*开始画车轮线条*/
  position: absolute;
  width: 1px;
  height: 200px;
  background: #ccc;
  margin: -5px 0 0 95px;
  z-index: 0;
}

.spoke:after {
  /*在后面插入两条*/
  content: "";
  position: absolute;
  width: 1px;
  height: 200px;
  background: #ccc;
  transform: rotate(120deg);
}

.spoke:before {
  /*在前面插入两条*/
  content: "";
  position: absolute;
  width: 1px;
  height: 200px;
  background: #ccc;
  transform: rotate(240deg);
}
/*轮胎线条完成*/

.spoke-container li:nth-child(2) {
  /*中心点旋转*/
  transform: rotate(30deg);
}

.inner-disc {
  /*画中心轴圆点*/
  background: #666;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  margin: -10px 0 0 -10px;
  top: 50%;
}

.inner-disc-2 {
  /*画轮胎中心轴的圆圈*/
  background: transparent;
  width: 6px;
  height: 6px;
  border: 2px solid #FFF;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  margin: -5px 0 0 -5px;
  top: 50%;
}

.cycle-wheel-back .inner-disc-2:after {
  /*插入后轮轴心齿轮*/
  content: "";
  background: transparent;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  position
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值