transition属性是一个很强大的3d动画属性,我动手试了一下,不少在网上很火的网页动画均可以用这个属性实现,只能说这个属性是在是太强大啦,本人在学习次属性以后才知道本身对css3的认识仍是偏少,如今我给你们介绍并实际实现下该属性。css
transition字面意思是变迁、变换、过分的意思,因此transition属性也离不开这个大体意思,其中该属性中的重要属性是: html
transition-property:指定过分的元素; 如:transition-property:background,就是指background属性参与这个过分。css3
transition-duration:指定这个过分持续时间;vim
transition-delsy:延迟过分时间;学习
transition-timing-function:指定时间过分类型; 如:ease\linear\ease-in\ease-out\ease-in-out\ 其中:ease是愈来愈慢,linear是匀速 运动,ease-in是先慢后快,ease-out是先快后慢,ease-in-out是先慢后快再慢动画
transition:all 0.3 ease; 其中all是指所有属性参与,0.3是过分时间,ease是过分类型;3d
如今应该对这个属性有了个基本的了解,其实知道了上述属性,咱们就能够动手作一些页面上的动画效果orm
.divt{ text-align: center; padding-top: 150px; margin-top: 30px; margin-bottom: 30px; } .divimg{ text-align: center; } .imgts{ width: 175px; height:175px; background-color: white; border: 2px solid blue; margin-top: 50px; margin-left: 50px; text-align: center; display: block; transform:rotate(10deg); transition:all 0.5s ease-in; box-shadow: 2px 2px 4px #9932CC; padding: 5px; margin: auto; } .imgts:hover{ transform:rotate(0deg) scale(1.05); box-shadow: 15px 15px 21px blue; } .divimg1{ width: 200px; height: 40px; background-color: pink; transition-property: background-color; transition-duration: 0.01s; transition-timing-function: ease; } .divimg1:hover{ background-color: yellowgreen; }
上述代码实现了鼠标悬停图片旋转和鼠标悬停改变颜色的功能,这个是否是很好用。htm
注:box-shadow是盒阴影属性,transform:rotate()属性在http://www.cnblogs.com/chrxc/p/5121347.html提过blog