css3动画那些事

css3动画那些事

ease,ease-in,ease-in-out,ease-out区别

描述
linear 规定以相同速度开始至结束的过渡效果(等于 cubic-bezier(0,0,1,1)) (匀速)
ease 规定慢速开始,然后变快,然后慢速结束的过渡效果(cubic-bezier(0.25,0.1,0.25,1))(相对于匀速,中间快,两头慢)
ease-in 规定以慢速开始的过渡效果(等于 cubic-bezier(0.42,0,1,1))(相对于匀速,开始的时候慢,之后快)
ease-out 规定以慢速结束的过渡效果(等于 cubic-bezier(0,0,0.58,1))(相对于匀速,开始时快,结束时候间慢)
ease-in-out 规定以慢速开始和结束的过渡效果(等于 cubic-bezier(0.42,0,0.58,1))(相对于匀速,(开始和结束都慢)两头慢)
cubic-bezier (n,n,n,n) 在 cubic-bezier 函数中定义自己的值。可能的值是 0 至 1 之间的数值

transform(变形)和transform-origin(变形原点)

transform(变形)和transform-origin(变形原点)的说明:
目前这两个属性得到了除去ie以外各个主流浏览器webkit,firefox,opera的支持,属性名分别为

  -webkit-transform,-moz-transform,-o-transform;

1、改变元素基点transform-origin

  • transform-origin是变形原点,也就是该元素围绕着那个点变形或旋转,该属性只有在设置了transform属性的时候起作用;

  • 因为我们元素默认基点就是其中心位置,换句话说我们没有使用transform-origin改变元素基点位置的情况下,transform进行的rotate,translate,scale,skew,matrix等操作都是以元素自己中心位置进行变化的。

  • 但有时候我们需要在不同的位置对元素进行这些操作,那么我们就可以使用transform-origin来对元素进行基点位置改变,使元素基点不在是中心位置,以达到你需要的基点位置。

  • 下面我们主要来看看其使用规则:

    transform-origin(X,Y):用来设置元素的运动的基点(参照点)。默认点是元素的中心点。其中X和Y的值可以是百分值,em,px,其中X也可以是字符参数值left,center,right;Y和X一样除了百分值外还可以设置字符值top,center,bottom 。

    • 语法:-moz-transform-origin: [ | | left | center | right ][ | | top | center | bottom ] ?
      transform-origin接受两个参数,它们可以是百分比,em,px等具体的值,也可以是left,center,right,或者 top,center,bottom等描述性参数 ;

    • top left | left top 等价于 0 0;

    • top | top center | center top 等价于 50% 0

    • right top | top right 等价于 100% 0

    • left | left center | center left 等价于 0 50%

    • center | center center 等价于 50% 50%(默认值)

    • right | right center | center right 等价于 100% 50%

    • bottom left | left bottom 等价于 0 100%

    • bottom | bottom center | center bottom 等价于 50% 100%

    • bottom right | right bottom 等价于 100% 100%

其中 left,center right是水平方向取值,对应的百分值为left=0%;center=50%;right=100%

top center bottom是垂直方向的取值,其中top=0%;center=50%;bottom=100%;

如果只取一个值,表示垂直方向值不变。

注:

transform-origin并不是transform中的属性值,他具有自己的语法。

但是他要结合transform才能起作用。

2、transform

  • transform属性可用于内联(inline)元素和块级(block)元素。它允许我们旋转、缩放和移动元素,他有几个属性值参数:
  • rotate(旋转)允许你通过传递一个度数值来转动一个对象;
  • scale是一个缩放功能,可以让任一元素变的更大。它使用一个或者两个正数和负数以及小数作为参数;当使用一个参数时表示X轴和Y轴的缩放相同;
  • translate就是基于X和Y 坐标重新定位元素,当使用一个参数时表示X轴和Y轴的参数相同;
  • skew倾斜(ps中的斜切),参数是度数,当使用一个参数时表示X轴和Y轴的参数相同;
  • matrix矩阵变换,就是基于X和Y 坐标重新定位元素,它使用6个参数

css3 mix-blend-mode 混合模式详解

混合方式有以下几种:

描述
mix-blend-mode: normal 正常
mix-blend-mode: multiply 正片叠底
mix-blend-mode: screen 滤色
mix-blend-mode: overlay 叠加
mix-blend-mode: darken 变暗
mix-blend-mode: lighten 变亮
mix-blend-mode: color-dodge 颜色减淡
mix-blend-mode: color-burn 颜色加深
mix-blend-mode: hard-light 强光
mix-blend-mode: soft-light 柔光
mix-blend-mode: difference 差值
mix-blend-mode: exclusion 排除
mix-blend-mode: hue 色相
mix-blend-mode: saturation; 饱和度
mix-blend-mode: color; 颜色
mix-blend-mode: luminosity; 亮度
mix-blend-mode: initial; 初始
mix-blend-mode: inherit; 继承
mix-blend-mode: unset; 复原

其中,multiply属性可以将图片的白色背景变成透明。

Animation动画属性

1、animation-name:需要绑定到选择器的 keyframe 名称(例如fadeOne)

2、animation-duration:完成动画所花费的时间,以秒或毫秒计

3、animation-timing-function:动画的速度曲线

4、animation-delay:动画开始之前的时间延迟

5、animation-iteration-count:动画循环的次数

6、animation-direction:规定动画是否反向轮播,normal是默认值,正常播放;alternate表示动画反向轮播

7、animation-fill-mode:规定动画在播放之前或之后,其动画效果是否可见

  • none 不改变默认行为
  • forwards 当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)
  • backwards 在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)
  • both 向前和向后填充模式都被应用

猜你喜欢

转载自blog.csdn.net/Rainy_X/article/details/83151224
今日推荐