CSS3 @keyframes动画规则

CSS3 动画属性


W3CSchool标准CSS使用语法  *@keyframes 针对不同浏览器兼容

@keyframes mymove
{
from {top:0px;}
to {top:200px;}
}

@-moz-keyframes mymove /* Firefox */
{
from {top:0px;}
to {top:200px;}
}

@-webkit-keyframes mymove /* Safari 和 Chrome */
{
from {top:0px;}
to {top:200px;}
}

@-o-keyframes mymove /* Opera */
{
from {top:0px;}
to {top:200px;}
}

注:目前浏览器都不支持 @keyframes 规则;Firefox 支持替代的 @-moz-keyframes 规则;Opera 支持替代的 @-o-keyframes 规则;Safari 和 Chrome 支持替代的 @-webkit-keyframes 规则。

 @keyframes 语法

html与css代码:div匀速向下运动

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">

		<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
		Remove this if you use the .htaccess -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<title>index</title>
		<meta name="description" content="">
		<meta name="author" content="boonya">

		<meta name="viewport" content="width=device-width; initial-scale=1.0">

		<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
		<link rel="shortcut icon" href="/favicon.ico">
		<link rel="apple-touch-icon" href="/apple-touch-icon.png">
		<style>
			div {
				width: 200px;
				height: 200px;
				background-color: #39B940;
				position:relative;
				-moz-animation:mymove 5s infinite;/*infinite无限循环*/
			}
			@-moz-keyframes mymove{
				from{top:0px;}
				to{top:300px;}
			}
		</style>
	</head>
	<body>
		<div> 
			<p>我是小妞妞。</p>
		</div>
		
	</body>
</html>

效果图


注:图片为静态,效果为动态,请参考http://www.w3school.com.cn/tiy/t.asp?f=css3_keyframes

带有多个 CSS 样式的多个 keyframe 选择器,html与css代码

<style>
			div {
				width: 200px;
				height: 200px;
				background-color: #39B940;
				position:relative;
				-moz-animation:mymove 5s infinite;	
				border-radius:25px;
			}
			@-moz-keyframes mymove{
				0%   {top:0px; 
				      left:0px; 
				      background:#A217A2;}
				25%  {top:0px; 
				      left:100px; 
				      background:#0FC646;}
				50%  {top:100px; 
				      left:100px; 
				      background:#DEAF24;}
				75%  {top:100px; 
				      left:0px; 
				      background:#0FC646;}
				100% {top:0px; 
				      left:0px; 
				      background:#A217A2;}
			}
		</style>
注:图片为静态,效果为动态,请参考 http://www.w3school.com.cn/tiy/t.asp?f=css3_keyframes4


  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值