CSS3(transform/transition/animation) 基础 总结
1、CSS3新增的样式(常用)
//颜色透明表示
rgba(0,0,0,.5) //圆角(定义角半径)
border-radius: 5px 10px 15px 20px; //文字/盒子阴影
text-shadow: 2px 3px 3px #000; //x方向,y方向,模糊半径,颜色(可定义多个阴影)
box-shadow: (inset) 2px 3px 3px #000; //内阴影,x方向,y方向,模糊半径,颜色(可多个阴影) //线性/径向渐变(没有纳入标准,需加浏览器内核前缀)
background-image: -linear/radial-gradient(left/left top/deg,#ccc,#000,red 50%,...);//起始方向,渐变的颜色(颜色占用的百分比)
background-image: -repeating-linear/radial-gradient(#ace 32%, #f96 36%); //重复渐变,不定方向默认90deg
以上样式比较简单易用,不过细心用起来会发现可以实现很多很意料之外的效果,很强大的。以后遇到其他什么3D效果、渐变突出button,金属文字效果什么的,以上代码便可以实现。随便举个简单的 模拟按钮button 应用,e.g:
//HTML
<div class="box"><a href="">btn</a></div> //CSS
.box a {
display: block;
width: 250px;
color: #fff;
font-size: 70px;
line-height: 1.5em;
margin: 30px auto;
text-decoration: none;
border: 1px solid rgba(0,0,0,.3);
//这部分是CSS3应用
border-radius: 5px;
text-shadow: 1px 1px 0 rgba(0,0,0,.4);
box-shadow: 0 0 1px rgba(0,0,0,.4);
background-image: -webkit-linear-gradient(90deg,#eaeaea,#c5c5c5); //webkit内核浏览器才能识别
}
.box a:hover {
background-image: -webkit-linear-gradient(-90deg,#eaeaea,#c5c5c5);
}
2、CSS3的变形:transform (需前缀,请自行添加)
rotate(30deg) //旋转
translate(x,y)/translateX(x)/translateY(y) //平移(x/y轴平移)
scale(x,y)/scaleX(x)/scaleY(y) //缩放
skew(x,y)/skewX(x)/skewY(y) //扭曲 //重定义变形的基点,以上属性都有其默认基点
transform-origin: x y; //定义多个属性
transform: rotate(30deg) scale(0.8,1.5) skew(30deg,-20deg);
3、CSS3的过渡变换:transition (需前缀,请自行添加)
//以下省略了前缀-transition
-property: name; //变换的属性名
-duration: time; //持续时间
-timing-function:
ease //默认,逐步变慢
linear //匀速
ease-in/out //加速/减速
ease-in-out //先加再减速
cubic-bezier(x1,y1,x2,y2) //自定义时间贝塞尔曲线
-delay: time; //推迟时间 //定义多个变换
transition: all .5s ease-in-out 1s;
参考:http://www.css88.com/archives/5403
4、CSS3动画制作:animation(keyframes) (需前缀,请自行添加)
首先,定义关键帧keyframes,学过flash动画的应该就很明白这个概念了
//百分比定义时间段
@keyframes name {
0% {属性状态}
10% {属性状态}
70% {属性状态}
100% {属性状态}
}
//从开始到结束的定义
@keyframes name {
from {属性状态}
to {属性状态}
}
然后,定义动画animation,大部分属性和transition的属性一样的,就没写的太详细了。
//以下省略了前缀-animation
-name: name; //动画名(关键帧的名称)
-duration: time; //持续时间
-timing-function: linear; //动画的时间曲线
-delay: time; //推迟时间
-iteration-count: infinite; //为数字,infinite指无限次
-direction: //动画方式
normal //默认值
alternate //奇数次时反方向执行动画
-play-state: running/paused; //动画状态:播放/停止 //定义多个属性
animate: name 3s ease-in-out 2s infinite alternate;
CSS3(transform/transition/animation) 基础 总结的更多相关文章
- css笔记——区分css3中的transform transition animation
出处:http://blog.csdn.net/dyllove98/article/details/8957232 CSS3中和动画有关的属性有三个 transform. transition ...
- css 动画 transform transition animation
1.transform transform 是通过在浏览器里面让网页元素 移动 旋转 透明 模糊 等方法来实现改变其外观的技术 -webkit-transform : translate(3em,0 ...
- css3动画transition animation
CSS动画简介 transition animation transition过渡:css3通过transitions属性引入时间概念,通过开始.结束状态自动计算中间状态,实现状态改变的过渡效果 ...
- css3的新特性transform,transition,animation
一.transform css3引入了一些可以对网页元素进行变换的属性,比如旋转,缩放,移动,或者沿着水平或者垂直方向扭曲(斜切变换)等等.这些的基础都是transform属性 transform属性 ...
- CSS Transform / Transition / Animation 属性的区别
back21 Jun 2011 Category: tech Tags: css 最近想UI的动画转到css3能吃进3d加速的属性上面来以加强动画的连贯性.只是对于css几个新加的属性不太熟悉,常常容 ...
- css3 - transform, transition 与 translate
零.序言 css 3 的新特性,很多都停留在听说而非实际使用.transform, transition, translate 这三长得实在太像,刚开始的时候总是迷迷糊糊,分不清它们的功能.而最近新接 ...
- css—动画(transform, transition, animation)
transform 静态属性,一旦写进style里面,会立即显示作用,无任何变化过程.(类似于left, right, top, bottom这类属性) 主要用来做元素的变形 改变元素样式的属性主要有 ...
- css3 tranform transition animation
tranform:对象图形变形 tranform的属性包括: 1.none 表示不进行变换: 2.rotate 旋转 transform:rotate(20deg) 旋转 ...
- CSS3之 transform和animation区别
CSS3 有3种和动画相关的属性:transform, transition, animation.其中 transform 描述了元素静态样式.而transition 和 animation 却都能 ...
随机推荐
- Lampda或Linq中的SqlFunctions.StringConvert()
要使用 Lampda或Linq中的SqlFunctions.StringConvert(), 需要引用命名空间using System.Data.Objects.SqlClient, 该函数可进行模拟 ...
- android在单身的对象和一些数据的问题被释放
正式接触android我们一直在开发了一段时间,该项目的第一个版本最终会很快结束. 当有它自己的测试.拥有android后台.同一时候打开了几个应用之后又一次切回到自己的app.发现报错了.经过排查, ...
- MySQL进口.sql文件和常用命令
MySQL进口.sql文件和常用命令 在MySQL Qurey Brower中直接导入*.sql脚本,是不能一次运行多条sql命令的.在mysql中运行sql文件的命令: mysql> so ...
- HDU 5281 Senior's Gun (贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5281 贪心题目,但是看看我的博客里边相关贪心的题解实在是少的可怜,这里就写出来供大家一起探讨. 题意还 ...
- bigdata_hadoop集群配置_内存分配
haoop集群 做好内存管理跟重要,不然经常会给抛出个 OutMemory ,内存溢出 以horntonworks给出推荐配置为样本,给出一种常见的Hadoop集群上各组件的内存分配方案.配置时 ...
- MVC推荐教程和文章列表
着手Getting Started Getting Started with ASP.NET MVC 5 (共11部分) Pluralsight ASP.NET MVC 5 Fundamentals( ...
- 前端学习笔记(zepto或jquery)——对li标签的相关操作(三)
对li标签的相关操作——八种方式遍历li标签并获取其值 $("ul>li").forEach(function(item,index){ alert(index+" ...
- SQL代理执行EXE可执行程序
原文:SQL代理执行EXE可执行程序 1.如果没有启用xp_cmdshell安全配置是不可以使用的-- 启用xp_cmdshellEXEC sp_configure 'xp_cmdshell', 1 ...
- Facebook HHVM 和 Hack 手册 --- 2. HHVM能做什么
HHWM简介: HHWM(HipHop VM) 是Facebook推出的用来执行PHP代码的虚拟机,它是一个PHP的JIT(Just-In- Time)编译器,同时具有产生快速代码和即时编译的优点. ...
- MonkenRunner通过HierarchyViewer定位控件的方法和建议(Appium/UIAutomator/Robotium姊妹篇)
1. 背景 在使用MonkeyRunner的时候我们经常会用到Chimchat下面的HierarchyViewer模块来获取目标控件的一些信息来辅助我们测试,但在MonkeyRunner的官网上是没有 ...