这篇文章主要为大家展示了“如何使用CSS3实现动画效果”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何使用CSS3实现动画效果”这篇文章吧。
Internet Explorer 10、Firefox 以及 Opera 支持 animation 属性。
Safari 和 Chrome 支持替代的 -webkit-animation 属性。
注释:Internet Explorer 9 以及更早的版本不支持 animation 属性。
定义和用法
animation属性是一个简写属性,用于设置六个动画属性:
animation-name
animation-duration
animation-timing-function animation-delay
animation-iteration-count animation-direction
语法
animation: name duration timing-function delay iteration-count direction;
关于keyframe的定义
Firefox支持替代的@-moz-keyframes规则;
Opera支持替代的@-o-keyframes规则;
Safari和Chrome支持替代的@-webkit-keyframes规则;
取值支持 0-100% 和from,to。
@keyframes move {
0% {
top: 0px;
left: 0px;
}
25% {
top: 200px;
left: 200px;
}
50% {
top: 100px;
left: 100px;
}
75% {
top: 200px;
left: 200px;
}
100% {
top: 0px;
left: 0px;
}
}
@keyframes move {
from {
top: 0px;
left: 0px;
}
to {
top: 0px;
left: 100px;
}
}demo 写了一个例子,地球绕太阳转
以下是代码
<!-- html 部分 --> <div style="width:700px; "> <div class="t"> <div class="t1"></div> </div> </div>
/* css 部分 */
@keyframes t {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@-webkit-keyframes t {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.t {
height: 500px;
width: 500px;
position: relative;
border-radius: 50%;
transform: scale(.8);
border: 1px solid #dedede;
&::before {
content: "";
width: 50px;
height: 50px;
background: radial-gradient(72px, #f00, #ff0, #080);
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
margin-top: -25px;
margin-left: -25px;
box-shadow: 0 0 37px #fcff4a;
}
.t1 {
height: 20px;
border-radius: 50%;
width: 20px;
margin-top: -10px;
top: 50%;
left: -10px;
background: radial-gradient(26px, #0082ff, #184608, #003ade);
position: absolute;
animation: t 3s infinite linear;
transform-origin: 260px center;
}
}
</style> 免责声明:本站发布的内容(图片、视频和文字)以原创、来自互联网转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系QQ:712375056 进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
Copyright © 2009-2021 56dr.com. All Rights Reserved. 特网科技 特网云 版权所有 珠海市特网科技有限公司 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站


