通过CSS3属性值的变化实现动画效果+触发这些动画…
2020-02-03 16:01:04来源:博客园 阅读 ()
通过CSS3属性值的变化实现动画效果+触发这些动画产生交互
css3过渡
transition
兼容性:IE10+
transition: none | all | property
默认为none
all 表示所有属性过渡
property 指定属性值,如color opacity
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> body{ margin:0 auto; background:#abcdef; } .box{ width:700px; height:700px; margin:0 auto; background:url(source/pic.png) center no-repeat; cursor: pointer; -webkit-transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); transform:rotate(0deg); -webkit-transition-property:transform; -moz-transition-property:transform; -ms-transition-property:transform; -o-transition-property:transform; transition-property:transform; } .box:hover{ -webkit-transform:rotate(180deg); -moz-transform:rotate(180deg); -ms-transform:rotate(180deg); -o-transform:rotate(180deg); transform:rotate(180deg); } </style> </head> <body> <div class="box"></div> </body> </html>
transition-duration 动画持续时间
transition-timing-function: linear | ease | ease-in | ease-out | ease-in-out
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> body{ margin:0 auto; background:#abcdef; } .box{ width:700px; height:700px; margin:0 auto; background:url(source/pic.png) center no-repeat; cursor: pointer; -webkit-transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); transform:rotate(0deg); -webkit-transition-property:transform; -moz-transition-property:transform; -ms-transition-property:transform; -o-transition-property:transform; transition-property:transform; -webkit-transition-duration:2s; -moz-transition-duration:2s; -ms-transition-duration:2s; -o-transition-duration:2s; transition-duration:2s; -webkit-transition-timing-function:linear;/*线性*/ -moz-transition-timing-function:linear; -ms-transition-timing-function:linear; -o-transition-timing-function:linear; transition-timing-function:linear; -webkit-transition-timing-function:ease;/*平滑*/ -moz-transition-timing-function:ease; -ms-transition-timing-function:ease; -o-transition-timing-function:ease; transition-timing-function:ease; -webkit-transition-timing-function:ease-in;/*缓入*/ -moz-transition-timing-function:ease-in; -ms-transition-timing-function:ease-in; -o-transition-timing-function:ease-in; transition-timing-function:ease-in; -webkit-transition-timing-function:ease-out;/*缓出*/ -moz-transition-timing-function:ease-out; -ms-transition-timing-function:ease-out; -o-transition-timing-function:ease-out; transition-timing-function:ease-out; -webkit-transition-timing-function:ease-in-out;/*缓入缓出*/ -moz-transition-timing-function:ease-in-out; -ms-transition-timing-function:ease-in-out; -o-transition-timing-function:ease-in-out; transition-timing-function:ease-in-out; } .box:hover{ -webkit-transform:rotate(180deg); -moz-transform:rotate(180deg); -ms-transform:rotate(180deg); -o-transform:rotate(180deg); transform:rotate(180deg); } </style> </head> <body> <div class="box"></div> </body> </html>
transition-delay 过渡延迟
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> body{ margin:0 auto; background:#abcdef; } .box{ width:700px; height:700px; margin:0 auto; background:url(source/pic.png) center no-repeat; cursor: pointer; -webkit-transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); transform:rotate(0deg); -webkit-transition-property:transform; -moz-transition-property:transform; -ms-transition-property:transform; -o-transition-property:transform; transition-property:transform; -webkit-transition-duration:2s; -moz-transition-duration:2s; -ms-transition-duration:2s; -o-transition-duration:2s; transition-duration:2s; -webkit-transition-timing-function:ease-in-out;/*缓入缓出*/ -moz-transition-timing-function:ease-in-out; -ms-transition-timing-function:ease-in-out; -o-transition-timing-function:ease-in-out; transition-timing-function:ease-in-out; -webkit-transition-delay:1s; -moz-transition-delay:1s; -ms-transition-delay:1s; -o-transition-delay:1s; transition-delay:1s; } .box:hover{ -webkit-transform:rotate(180deg); -moz-transform:rotate(180deg); -ms-transform:rotate(180deg); -o-transform:rotate(180deg); transform:rotate(180deg); } </style> </head> <body> <div class="box"></div> </body> </html>
transtion简写
transition: property duration timing-function delay
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> body{ margin:0 auto; background:#abcdef; } .box{ width:700px; height:700px; margin:0 auto; background:url(source/pic.png) center no-repeat; cursor: pointer; -webkit-transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); transform:rotate(0deg); -webkit-transition:transform 2s ease-in-out 1s; -moz-transition:transform 2s ease-in-out 1s; -ms-transition:transform 2s ease-in-out 1s; -o-transition:transform 2s ease-in-out 1s; transition:transform 2s ease-in-out 1s; } .box:hover{ -webkit-transform:rotate(180deg); -moz-transform:rotate(180deg); -ms-transform:rotate(180deg); -o-transform:rotate(180deg); transform:rotate(180deg); -webkit-transition:transform 2s ease-in-out 1s; -moz-transition:transform 2s ease-in-out 1s; -ms-transition:transform 2s ease-in-out 1s; -o-transition:transform 2s ease-in-out 1s; transition:transform 2s ease-in-out 1s; } </style> </head> <body> <div class="box"></div> </body> </html>
原文链接:https://www.cnblogs.com/chenyingying0/p/12256719.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- ie8下透明度处理 2020-06-11
- CSS3 2020-06-05
- css:css3(圆角边框、盒子阴影、文字阴影) 2020-06-05
- CSS常用属性(入门级),持续更新 2020-05-22
- 2.CSS3选择器 2020-05-17
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash