当前位置:Gxlcms > css > css中动画属性的实现方法(附代码)

css中动画属性的实现方法(附代码)

时间:2021-07-01 10:21:17 帮助过:31人阅读

本篇文章给大家带来的内容是关于css中动画属性的实现方法(附代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

一、css动画(animation)属性可以逐渐地从一个值变化到另一个值,比如尺寸大小、数量、百分比、位置和颜色。

二、实现方法:

1.定义动画(slideOut为自定义的动画名称)

  1. @-webkit-keyframes slideOut{
  2. 0%{top:-30px; opacity: 0;}
  3. 100%{top:0px; opacity: 1;}
  4. }
  5. @-moz-keyframes slideOut{
  6. 0%{top:-30px; opacity: 0;}
  7. 100%{top:0px; opacity: 1;}
  8. }
  9. @-o-keyframes slideOut{
  10. 0%{top:-30px; opacity: 0;}
  11. 100%{top:0px; opacity: 1;}
  12. }
  13. @-ms-keyframes slideOut{
  14. 0%{top:-30px; opacity: 0;}
  15. 100%{top:0px; opacity: 1;}
  16. }
  17. @keyframes slideOut{
  18. 0%{top:-30px; opacity: 0;}
  19. 100%{top:0px; opacity: 1;}
  20. }

2、调用动画

  1. -webkit-animation: slideOut 0.5s ease-in-out 0.3s backwards;
  2. -moz-animation: slideOut 0.5s ease-in-out 0.3s backwards;
  3. -o-animation: slideOut 0.5s ease-in-out 0.3s backwards;
  4. -ms-animation: slideOut 0.5s ease-in-out 0.3s backwards;
  5. animation: slideOut 0.5s ease-in-out 0.3s backwards;

三、动画用到的属性有background/border/border/box-shadow/clip/color/column/filter/flex/font/letter-spacing/line-height/margin/opacity/outline/perspective/text/vertical-align/visibility/word-spacing/z-index等等,基本上所以元素了。

相关推荐:

CSS动画之Tranistion_html/css_WEB-ITnose

css动画制作——CSS animate

以上就是css中动画属性的实现方法(附代码)的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行