当前位置:   article > 正文

css anminate 加载中三个点点动态出现

css anminate 加载中三个点点动态出现

期待效果:

核心代码:

css3 anminate方法

  1. //html
  2. <div>加载中<span id="dot">...</span></div>
  3. //css
  4. <style>  
  5. #dot {
  6. display: inline-block;
  7. width: 1.5em;
  8. vertical-align: bottom;
  9. overflow: hidden;
  10. animation: dotting 3s infinite step-start;
  11. }
  12. @keyframes dotting{
  13. 0% { width: 0; margin-right: 1.5em; }
  14. 33% { width: .5em; margin-right: 1em; }
  15. 66% { width: 1em; margin-right: .5em; }
  16. 100% { width: 1.5em; margin-right: 0;}
  17. }
  18. </style>

一、代码实操

html代码:

  1. <div class="contanier">
  2. <img
  3. :src="
  4. getAssetsFile(
  5. data.isFinish == 0
  6. ? `smartCabin/loadingImg/isLoading_bg.png`
  7. : `smartCabin/loadingImg/isErr_bg.png`
  8. )
  9. "
  10. />
  11. <div class="imgTitle">加载中<span id="dot">...</span></div>
  12. </div>

css:

  1. .contanier {
  2. width: 50%;
  3. height: 80%;
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: center;
  7. align-items: center;
  8. .imgTitle {
  9. font-size: calc(100vw * 18 / 1920);
  10. color: #757575;
  11. line-height: 21px;
  12. letter-spacing: 2px;
  13. #dot {
  14. display: inline-block;
  15. width: 1.5em;
  16. vertical-align: bottom;
  17. overflow: hidden;
  18. animation: dotting 0.5s infinite step-start;
  19. }
  20. @keyframes dotting {
  21. 0% {
  22. width: 0;
  23. margin-right: 1.5em;
  24. }
  25. 33% {
  26. width: 0.5em;
  27. margin-right: 1em;
  28. }
  29. 66% {
  30. width: 1em;
  31. margin-right: 0.5em;
  32. }
  33. 100% {
  34. width: 1.5em;
  35. margin-right: 0;
  36. }
  37. }
  38. }
  39. .imgTitle2 {
  40. .imgTitle;
  41. color: red;
  42. }

以上就是全部实现代码。。。

以下是理论知识

二、理论知识:

使用简写属性 animation 一次性设置所有动画属性,很方便。

anminate:CSS animation 属性是animation-durationicon-default.png?t=N7T8https://developer.mozilla.org/zh-CN/docs/Web/CSS/animation-duration详情看MDN

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/386820
推荐阅读
相关标签
  

闽ICP备14008679号