css 3 动画
1.transition,其作用是:平滑的改变CSS的值。无论是点击事件,焦点事件,还是鼠标hover,只要值改变了,就是平滑的,就是动画。
transition 属性介绍:
transition-property :* //指定过渡的性质,比如transition-property:backgrond 就是指backgound参与这个过渡
transition-duration:*//指定这个过渡的持续时间
transition-delay:* //延迟过渡时间
transition-timing-function:*//指定过渡类型,有ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier
例如:
.trans {
-webkit-transition-property: background-color;
-webkit-transition-duration: 0.3s;
-webkit-transition-timing-function: ease;
}
.trans:hover {
background-color: #486AAA;
color: #fff;
}
注意浏览器的兼容性。
2.transform ,指变换,使用过photoshop的人应该知道里面的Ctrl+T自由变换。transform就是指的这个东西,拉伸,压缩,旋转,偏移。
transform 属性介绍:
旋转rotate
扭曲skew
缩放scale
移动translate
矩阵变形matrix
以rotate为例,3D Transform 中 rotate 有三种方法,rotateX(angle) X轴旋转,rotateY(angle) Y轴旋转,rotateZ(angle) Z轴旋转
.trans_skew { transform: skew(35deg); }
.trans_scale { transform:scale(1, 0.5); }
.trans_rotate { transform:rotate(45deg); }
.trans_translate { transform:translate(10px, 20px); }
例如:
.trans_effect {
-webkit-transition:all 2s ease-in-out;
-moz-transition:all 2s ease-in-out;
-o-transition:all 2s ease-in-out;
-ms-transition:all 2s ease-in-out;
transition:all 2s ease-in-out;
}
.trans_effect:hover {
-webkit-transform:rotate(720deg) scale(2,2);
-moz-transform:rotate(720deg) scale(2,2);
-o-transform:rotate(720deg) scale(2,2);
-ms-transform:rotate(720deg) scale(2,2);
transform:rotate(720deg) scale(2,2);
}
注意浏览器的兼容性。
3.animation
使用:
@-webkit-keyframes glow {
0% {
-webkit-box-shadow: 0 0 12px rgba(72, 106, 170, 0.5);
border-color: rgba(160, 179, 214, 0.5);
}
100% {
-webkit-box-shadow: 0 0 12px rgba(72, 106, 170, 1.0), 0 0 18px rgba(0, 140, 255, 1.0);
border-color: rgba(160, 179, 214, 1.0);
}
}
.anim_image {
padding:3px;
border:1px solid #beceeb;
background-color:white;
-moz-box-shadow: 0 0 8px rgba(72, 106, 170, 0.5);
-webkit-box-shadow: 0 0 8px rgba(72, 106, 170, 0.5);
box-shadow: 0 0 8px rgba(72, 106, 170, 0.5);
}
.anim_image:hover {
background-color:#f0f3f9;
-webkit-animation-name: glow;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
-webkit-animation-timing-function: ease-in-out;
}
注意浏览器的兼容性
此案例演示效果:http://www.zhangxinxu.com/study/201011/css3-transition-animate-demo-7.html
4.transition 与 transform 综合使用案例(两图片轮流播放):
img{
width: 100px;
height:100px;
transition: all 1s ease-in-out ;
cursor: pointer;
}
.img_top{
position: absolute;
transform: scale(0,0);
opacity:;
}
.anim_box:hover .img_top{
opacity:;
transform: scale(1, 1);
}
.anim_box:hover .img_bottom{
transform: scale(0,0);
}
html:
<div class="anim_box">
<img class="img_top" src="static/image/palm.jpg">
<img class="img_bottom" src="static/image/trees.jpg">
</div>
案例效果:http://www.zhangxinxu.com/study/201011/css3-transition-animate-demo-11.html
css 3 动画的更多相关文章
- 第四十二课:基于CSS的动画引擎
由于低版本浏览器不支持css3 animation,因此我们需要根据浏览器来选择不同的动画引擎.如果浏览器支持css3 animation,那么就使用此动画引擎,如果不支持,就使用javascript ...
- Effeckt.css项目:CSS交互动画应用集锦
目前,网上有大量基于CSS转换的实验和示例,但它们都过于分散,而Effeckt.css的目标就是把所有基于CSS/jQuery动画的应用集中起来,例如:弹窗.按钮.导航.列表.页面切换等等. Effe ...
- 基于animation.css实现动画旋转特效
分享一款基于animation.css实现动画旋转特效.这是一款基于CSS3实现的酷炫的动画旋转特效代码.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class ...
- vue中使用第三方插件animate.css实现动画效果
vue中使用第三方插件animate.css实现动画效果1.首先先引入第三方类animated.css2.将你所需要动画的标签用包裹起来3.在transition元素中添加enter-active-c ...
- CSS波纹动画
波纹动画 在此运用到css的动画属性,以及背景等相关属性. 值得一说的是下面代码中一直写到的这样一行代码:filter: alpha(opacity=0~100) ,这是考虑到浏览器兼容的问题. IE ...
- css hover 动画 transition:background-color 0.2s,color 0.2s; 外层套内层,正常是 里外层 鼠标上来 外层有hover,如果就想到里层hover触发外层hover,要用外层position 定义绝对定位,内层的hover跳出外层的div,这样视觉上就是两个单独的div,进行内外层联动。
css hover 动画 transition:background-color 0.2s,color 0.2s; 外层套内层,正常是 里外层 鼠标上来 外层有hover,如果就想到里层hover触发 ...
- CSS变形动画
CSS变形动画 前言 在开始介绍CSS变形动画之前,可以先了解一下学习了它之后能做什么,有什么用,这样你看这篇文章可能会有一些动力. 学习了CSS变形动画后,你可以为你的页面做出很多炫酷的效果,如一个 ...
- CSS帧动画
CSS帧动画 基础知识 通过定义一段动画中的关键点.关键状态来创建动画.@Keyframes相比transition对动画过程和细节有更强的控制. 过渡动画是两个状态间的变化,帧动画可以处理动画过程中 ...
- css keyframes动画属性设置
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
随机推荐
- Java线程问题分析定位
Java线程问题分析定位 分析步骤: 1.使用top命令查看系统资源占用情况,发现Java进程占用大量CPU资源,PID为11572: 2.显示进程详细列表命令:ps -mp 11572 -o THR ...
- 转载:log4j.properties log4j.xml 路径问题
自动加载配置文件: (1)如果采用log4j输出日志,要对log4j加载配置文件的过程有所了解.log4j启动时,默认会寻找source folder下的log4j.xml配置文件,若没有,会寻找lo ...
- A股各概念板块龙头股大全
A股各概念板块龙头股大全一.新兴信息产业龙头 1.车联网龙头——软控股份002073 启明信息002232.荣之联002642 2.通信网络龙头——恒宝股份002104 3.通信设备制造龙头——新海宜 ...
- 照片灰蒙蒙?用PS的曲线功能来解决 (转)
原文地址:http://realjasonc.blog.163.com/blog/static/16475932520107594048957/ 上次,给大家看了几张较为典型的直方图.其实直方图的状态 ...
- 转自pnljs 委托(Func<int,bool>)
随笔- 147 文章- 0 评论- 16 Func的介绍 经常看到 Func<int, bool>...这样的写法,看到这样的就没有心思看下去了.我们学技术还是需要静下心来. 对Fu ...
- IBatis 简易框架搭建
1.练习框架 ibatis主要dll介绍 IBatisNet.Common.dll 由DataAccess和DataMapper组成的共享程序集 IBatisNet.Common.Logging.Lo ...
- npm -v 一直闪
一直闪一般是配置搞错了 参考: windows安装完nodejs后做了相关环境变量配置后,cmd输入npm没反应啊 就光标一直闪 node是正常的 或者 https://segmentfault.co ...
- Android using Accelerometer
http://code.tutsplus.com/tutorials/using-the-accelerometer-on-android--mobile-22125 public class Mai ...
- Appium移动自动化测试之问题总结
1.运行该测试用例,报如下错误 java.lang.NoSuchMethodError: org.openqa.selenium.remote.ErrorHandler.<init>(Lo ...
- Linux入门学习 常用命令
cd命令 功能是切换到指定的目录:命令格式:cd [目录名]有几个符号作为目录名有特殊的含义:"/"代表根目录.".."代表上一级目录."~" ...