css3圆环旋转效果动画怎么做

html-css07

css3圆环旋转效果动画怎么做,第1张

1、首先新建一个html空白文档,取名字叫做css3动画,保存一下。

2、然后写html结构,只需要一个div元素即可,class名字叫做img

3、设置其边框为不同的颜色,边框宽度设置成100px。

4、因为是圆环,所以我们用到了css3的圆角效果,设置圆角为50%,也就是border-radius:50%,看一下效果。

5、接下来就是关键的步骤了,也就是添加动画效果。输入以下代码

6、来看一下最后的效果,还是不错的。

一、实现CSS3无限循环动画代码示例。

代码如下:

CSS:

@-webkit-keyframes gogogo {

0%{

-webkit-transform: rotate(0deg)

border:5px solid red

}

50%{

-webkit-transform: rotate(180deg)

background:black

border:5px solid yellow

}

100%{

-webkit-transform: rotate(360deg)

background:white

border:5px solid red

}

}

.loading{

border:5px solid black

border-radius:40px

width: 28px

height: 188px

-webkit-animation:gogogo 2s infinite linear

margin:100px

}

扩展资料

实现动画无限循环所需要的CSS属性说明:

1、infinite

在animation后面加上infinite就可以无限循环,另外还可以做反向循环使用animation-direction

2、animation-name

规定需要绑定到选择器的 keyframe 名称。

3、animation-duration

规定完成动画所花费的时间,以秒或毫秒计。

4、animation-timing-function

规定动画的速度曲线。

5、animation-delay

规定在动画开始之前的延迟。

6、animation-iteration-count

规定动画应该播放的次数。

7、animation-direction

规定是否应该轮流反向播放动画。

原理就是,先定义一个元素 ,然后定义动画XYZ轴偏移。

body > div > div:after {

    content: ""

    position: absolute

    top: -5px

    box-shadow: 0 0 12px #fff

    left: 50%

    margin-left: -5px

    width: 5px

    height: 5px

    border-radius: 50%

    background-color: #fff

    -webkit-animation: particle_ 2s infinite linear

    animation: particle_ 2s infinite linear

} body > div:nth-of-type(4) > div, body > div:nth-of-type(4) > div:after {

    -webkit-animation-delay: -1.5s

    animation-delay: -1.5s

}

body > div > div {

    width: 200px

    height: 200px

    position: relative

    -webkit-transform-style: preserve-3d

    -webkit-animation: trail_ 2s infinite linear

    transform-style: preserve-3d

    animation: trail_ 2s infinite linear

}

实施步骤:

建立一个BOX

在BOX中制作一个元素。

CSS动画定义BOX旋转按照你的轨迹。

通过。

-webkit-transform:rotateY( 0deg ) rotateZ( 0deg )  rotateX( 0deg )

         -moz-transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

      -o-transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

              transform:rotateY( 0deg ) rotateZ( 0deg ) rotateX( 0deg )

来定义旋转方向,0是不旋转。0-360度是一圈。

       -webkit-transition:transform 1s

transition:transform 1s

这是设置动画时间。

一个BOX完成后,复制box,摆在统一中心点后,设置Z轴的数字。