css3 实现动画效果,怎样使他无限循环动下去?

html-css012

css3 实现动画效果,怎样使他无限循环动下去?,第1张

一、实现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

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

像这种需求你可以用js或者jQuery编写。

如果不想使用js或者jquery,那么用css的过渡属性代码如下:

鼠标滑入,出现效果

transition: right  .7s ease

right为过渡的属性,可以是宽高,top/lelft/right/bottom/opacity等等。只要记住transition不能过渡display就行。

.7s 为过渡所需要的时间,ease为过渡的样式,是匀速过渡还是先快后慢等等。

如果没有鼠标事件,那么就需要用到css3的动画,animation。css3的动画详情卡查看https://mengkedu.com/

简单的做法:

首先设置元素出状态 top (js 的 clientHeight)

利用 css3 transition,(例:transition: top .2s ease)

然后通过事件改变 top 的值,达到滑动的效果(top: client页面高度 ->top: 0)

(以上仅为参考,该元素需要 position: fixed)

复杂的可以再去上网寻找下各种例子,甚至是尝试模仿一些app的效果自己做点东西出来