CSS3中transition功能怎么使用?

零下一度
发布: 2017-06-28 09:40:53
原创
2896人浏览过

1.transition功能

transition属性的使用方法:transition:property duration timing-function;

其中property表示对哪个属性进行平滑过渡,duration表示多长时间完成属性值的平滑过渡,timing-function表示通过什么方法来进行平滑过渡。

多平滑过渡示例:

 1 <!DOCTYPE html> 2 <html lang="zh-CN"> 3 <head> 4     
 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5    
 <meta http-equiv="x-ua-compatible" content="IE=edge"> 6     
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 7     
 <title>测试</title> 8 </head> 9 <body>10 <div id="test"></div>11 <style>12     #test{13         
 width: 500px;14         height: 500px;15         background-color: yellow;16         /*css动画*/17         
 transform: rotate(0);18         -webkit-transition: transform 0.5s linear, width 0.5s linear;19         -moz-transition: transform 0.5s linear, width 0.5s linear;20         -ms-transition: transform 0.5s linear, width 0.5s linear;21         -o-transition: transform 0.5s linear, width 0.5s linear;22         transition: transform 0.5s linear, width 0.5s linear;23     }24     #test:hover{25         width: 200px;26         transform: rotate(180deg);27     }28 </style>29 </body>30 </html>
登录后复制

2.animation功能

使用示例:

乐活途购物分享社区
乐活途购物分享社区

beta v1.1版本为第一个版本,简单的整合了基础功能,各位站长拿到程序后,不要纠结后台的功能简单,后续将不断更新扩展。在beta v1.1版本使用过程中遇到什么问题,请登录 www.loftto.com 进行反馈! 安装说明######重要提醒:程序不支持二级目录安装,请使用一级目录或二级目录绑定!#第一步,确定你的服务器支持PHP+mysql。#第二步,确定你的服务器开启了gd库。#第三步,

乐活途购物分享社区 0
查看详情 乐活途购物分享社区
 1 <!DOCTYPE html> 2 <html lang="zh-CN"> 3 <head> 4     
 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5     
 <meta http-equiv="x-ua-compatible" content="IE=edge"> 6     
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 7     
 <title>测试</title> 8 </head> 9 <body>10 <div id="test"></div>11 <style>12 /*animation动画*/13     
 @-webkit-keyframes colorChange {14         0%{15             background-color: deepskyblue;16         }        
 50%{18             
 background-color: red;19         }20         
 100%{21             background-color: deepskyblue;22         }23     }24     
 #test{25         width:500px;26         height: 500px;27         
 background-color: deepskyblue;28     }29     #test:hover{30         animation-name: colorChange;         
 animation-duration: 1s;32         animation-timing-function: linear;33     }34 </style>35 </body>36 
 </html>
登录后复制

实现动画的方法:

立即学习前端免费学习笔记(深入)”;

方法 属性值的变化速度
linear 在动画开始时与结束时以同样的速度进行变化
ease-in 动画开始时速度很慢,然后速度沿曲线值进行加快
ease-out 动画开始时速度很快,然后速度沿曲线值进行放慢
ease 动画开始时速度很慢,然后速度沿曲线值进行加快,然后再沿曲线值进行放慢
ease-in-out 动画开始时速度很慢,然后速度沿曲线值进行加快,然后再沿曲线值进行放慢

以上就是CSS3中transition功能怎么使用?的详细内容,更多请关注php中文网其它相关文章!

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号