Home >Web Front-end >HTML Tutorial >css3的@keyframes用法介绍_html/css_WEB-ITnose

css3的@keyframes用法介绍_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:28:441821browse

css3的@keyframes用法介绍:
keyframes翻译成汉语是"关键帧",如果会一点flash知识的话,对它应该不陌生,原来和flash是一样的。
我们可以利用它定义相关的状态,由此产生动画效果。
语法结构:

@keyframes animationname {keyframes-selector {css-styles;}}

参数解析:
1.animationname:必需,规定动画的名称。
2.keyframes-selector:必需,用来规定动画的时长,可以是百分比的形式,也可以是from to的形式。
3.css-styles:必需,css样式属性代码。
代码实例:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style> div{  width:100px;  height:100px;  background:red;  position:relative;  animation:mymove 5s infinite;  -moz-animation:mymove 5s infinite;/* Firefox */  -webkit-animation:mymove 5s infinite;/* Safari and Chrome */  -o-animation:mymove 5s infinite;/* Opera */}@keyframes mymove{  0% {top:0px; left:0px; background:red;}  25% {top:0px; left:100px; background:blue;}  50% {top:100px; left:100px; background:yellow;}  75% {top:100px; left:0px; background:green;}  100% {top:0px; left:0px; background:red;}}/* Firefox */@-moz-keyframes mymove{  0% {top:0px; left:0px; background:red;}  25% {top:0px; left:100px; background:blue;}  50% {top:100px; left:100px; background:yellow;}  75% {top:100px; left:0px; background:green;}  100% {top:0px; left:0px; background:red;}}/* Safari and Chrome */@-webkit-keyframes mymove{  0% {top:0px; left:0px; background:red;}  25% {top:0px; left:100px; background:blue;}  50% {top:100px; left:100px; background:yellow;}  75% {top:100px; left:0px; background:green;}  100% {top:0px; left:0px; background:red;}}/* Opera */@-o-keyframes mymove{  0% {top:0px; left:0px; background:red;}  25% {top:0px; left:100px; background:blue;}  50% {top:100px; left:100px; background:yellow;}  75% {top:100px; left:0px; background:green;}  100% {top:0px; left:0px; background:red;}}</style></head><body><div></div></body></html>

上面就是一个简单的动画效果,比较简单,更多内容可以参阅相关阅读。
相关阅读:
1.@keyframes可以参阅CSS3的@keyframes用法详解一章节。
2.animation属性可以参阅CSS3的animation属性用法详解一章节。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=15401

更多内容可以参阅:http://www.softwhy.com/divcss/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn