从零开始学 Web 之 CSS3(六)动画animation,Web字体

 大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新......

  • github:https://github.com/Daotin/Web
  • 微信公众号:Web前端之巅
  • 博客园:upload/201810201040200818.png" style="margin: 0px; padding: 0px; border: 0px; max-width: 820px; height: auto;" alt="" />

    一、动画

    1、创建动画

    好的前端工程师,会更注重用户的体验和交互。那么动画就是将我们的静态页面,变成具有灵动性,为我们的界面添加个性的一种方式。

    一个动画至少需要两个属性:

    animation-name :动画的名字(创建动画时起的名字,如下为 moveTest)

    animation-duration :动画的耗时

    animation-name: moveTest; animation-duration: 2s;

    如需在 CSS3 中创建动画,需要学习 @keyframes 规则。@keyframes 规则用于创建动画。在 @keyframes 中规定某项 CSS 样式,就能创建由当前样式逐渐改为新样式的动画效果。

    使用 @keyframes关键字来创建动画。

    @keyframes moveTest {   /*百分比是指整个动画耗时的百分比*/   0% {     transform: translate(0px, 0px);   }   50% {     transform: translateY(200px);   }   100% {     transform: translate(200px,200px);   } }

    其中,百分比是指整个动画耗时的百分比。

    示例:

    <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <title>Document</title>     <style>         div {             width: 100px;             height: 100px;             background-color: blue;              animation-name: moveTest;             animation-duration: 2s;         }          @keyframes moveTest {             0% {                 transform: translate(0px, 0px);             }             50% {                 transform: translateY(200px);             }             100% {                 transform: translate(200px,200px);             }         }     </style> </head> <body>     <div></div> </body> </html>

    关键字:
50000+
5万行代码练就真实本领
17年
创办于2008年老牌培训机构
1000+
合作企业
98%
就业率

联系我们

电话咨询

0532-85025005

扫码添加微信