网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

css3中animation动画属性的使用方法

这篇文章将为大家详细讲解有关css3中animation动画属性的使用方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

成都创新互联从2013年创立,是专业互联网技术服务公司,拥有项目网站制作、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元茶陵做网站,已为上家服务,为茶陵各地企业和个人服务,联系电话:18982081108

CSS主要是用于描绘网页的样式和布局而CSS3 是最新的 CSS 标准,提供了更多的方法而且使用CSS3,可以创建动画,使网页内容更加丰富今天将和大家分享css3中的动画属性——animation

注意在使用过程中浏览器兼容问题

Internet Explorer 10、Firefox 以及 Opera 支持 animation 属性。

Safari 和 Chrome 支持 -webkit-animation 属性

所以在写程序的过程中应考虑到浏览器兼容问题

animation 属性

用于设置六个动画属性:

(1)animation-name:规定动画的名称。

animation-name:demo//Internet Explorer 10、Firefox 以及 Opera 浏览器中
-webkit-animation-name:demo//Safari 和 Chrome

(2)animation-duration:完成动画所花费的时间(以秒和毫秒为单位)

animation-duration:3s;
-webkit-animation-duration:3s;

(3)animation-timing-function:动画速度曲线

linear :以匀速播放

ease :刚开始动画速度慢然后加快在结束时变慢  (默认)

ease-in :指动画以低速开始

ease-out :指动画以低速结束。

ease-in-out :动画以低速开始和结束

cubic-bezier(n,n,n,n) :在 cubic-bezier 函数中设置想要的值,是从 0 到 1 的数值

animation-timing-function:ease;
-webkit-animation-timing-function:ease;

(4)animation-delay:动画开始延迟时间

animation-delay:3s;
-webkit-animation-delay:3s;

(5)animation-iteration-count:动画播放的次数

n: 自定义动画播放次数的数值

infinite :指动画无限次循环播放

animation-iteration-count:4;//循环四次
-webkit-animation-iteration-count:infinite;//循环无数次

(6)animation-direction:动画是否轮流反向播放

normal   动画应该正常播放  (默认)

alternate    动画应该轮流反向播放

animation-direction:normal;
-webkit-animation-direction:alternate;

让一个小方块按照右下左上的方向进行运动

div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:demo;
animation-iteration-count:infinite;
animation-duration:2s;
animation-timing-function:ease;
animation-delay:0.1s;
animation-direction: alternate; 
}
/* Safari and Chrome 浏览器*/
-webkit-animation:demo;/*设置动画名称*/
-webkit-animation-iteration-count:infinite;/*动画执行次数*/
-webkit-animation-duration:5s;/*动画花费时间*/
-webkit-animation-timing-function:ease;/*动画速度*/
-webkit-animation-delay:2s;/*动画延迟*/
-webkit-animation-direction: alternate; /*动画是否反向*/
}
/*设置动画运行区域*/
@keyframes demo
{
	0% {background-color: pink;left:0;top:40px;}
	25%{background-color: hotpink;left:300px;top:40px;}
	50%{background-color: yellow;left:300px;top:340px;}
	75%{background-color: blue;left:0;top:340px;}
	100%{background-color: green;left:0;top:30px;}
}
/*Safari and Chrome浏览器*/
@-webkit-keyframes demo
{
    0% {background-color: pink;left:0;top:40px;}
	25%{background-color: hotpink;left:300px;top:40px;}
	50%{background-color: yellow;left:300px;top:340px;}
	75%{background-color: blue;left:0;top:340px;}
	100%{background-color: green;left:0;top:30px;}
}

效果图:

css3中animation动画属性的使用方法

关于css3中animation动画属性的使用方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


文章题目:css3中animation动画属性的使用方法
网页地址:http://bjjierui.cn/article/ppcios.html

其他资讯