分享

动画效果-过渡

 时间剧毒 2019-06-10

过渡动画:

  1. 通过 CSS3,我们可以在不使用 Flash 动画或 JavaScript 的情况下,当元素从一种样式变换为另一种样式时为元素添加效果。

  2. CSS3 过渡是元素从一种样式逐渐改变为另一种的效果。要实现这一点,必须规定两项内容:把效果添加到哪个 CSS 属性上/规定效果的时长


过渡动画的属性:
  1. transition 简写属性,用于在一个属性中设置四个过渡属性。



  2. transition-property 规定应用过渡的 CSS 属性的名称。
    • none 没有属性会获得过渡效果。

    • all 所有属性都将获得过渡效果。

    • 属性名称


  3. transition-duration 定义过渡效果花费的时间。默认是 0。单位是秒或毫秒


  4. transition-timing-function 规定过渡效果的时间曲线。默认是 "ease"。
    • 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 之间的数值。


  5. transition-delay 规定过渡效果何时开始。默认是 0。


<!DOCTYPE html>

<html lang="zh-cn">

<head>

<meta charset="utf-8">

<title>6-52课堂演示</title>

<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

 <div id="div1">过渡动画1</div>

 <div id="div2">过渡动画2</div>

 <div id="div3">过渡动画3</div>

 <div id="div4">过渡动画4</div>

 <div id="div5">过渡动画5</div>

</body>

</html>

@charset="UTF-8";

div{

width: 300px;

height: 150px;

margin: 30px;

font-size: 28px;

}

#div1{

background: red;

transition-property: width;

transition-duration: 1s;

transition-timing-function: ease;

}

#div1:hover{

background: green;

width: 150px;

}

#div2{

background: orange;

transition-property: width;

transition-duration: 1s;

transition-timing-function: cubic-bezier(0.2,0.4,0.5,1);

transition-delay:2s;

}

#div2:hover{

background: green;

width: 150px;

}

#div3{

background: blue;

transition: all 2s ease-in-out 0s;

}

#div3:hover{

background: green;

width: 150px;

}

#div4{

background: rgba(120,60,30,0.8);

transition: width 1s ease ,

background 2s linear;

}

#div4:hover{

background: green;

width: 150px;

}

#div5{

background: rgba(20,60,130,0.8);

transition: all 1s ease 0.5s;

}

#div5:hover{

background: green;

width: 150px;

transform: rotate(360deg);

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多