Escalade loading

ezgif.com-video-to-gif.gif

HTML

  <svg>
  <g>
    <path d="M 50,100 A 1,1 0 0 1 50,0"/>
  </g>
  <g>
    <path d="M 50,75 A 1,1 0 0 0 50,-25"/>
  </g>
  <defs>
    <linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" style="stop-color:#FF56A1;stop-opacity:1" />
      <stop offset="100%" style="stop-color:#FF9350;stop-opacity:1" />
    </linearGradient>
  </defs>
</svg>

CSS

$transition-duration: 2s;
$path-length: 157px; // Retrieved using SVG's getTotalLength()

html, body {
  width: 100%;
  height: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

svg {
  overflow: visible;
  width: 100px;
  height: 150px;
  
  g {
    animation: slide $transition-duration linear infinite;
    
    &:nth-child(2) {
      animation-delay: $transition-duration / 4;
      
      path {
        animation-delay: $transition-duration / 4;
        stroke-dasharray: 0px $path-length + 1;
        stroke-dashoffset: 1px;
      }
    }
  }
  
  path{
    stroke: url(#gradient);
    stroke-width: 20px;
    stroke-linecap: round;
    fill: none;
    stroke-dasharray: 0 $path-length;
    stroke-dashoffset: 0;
    animation: escalade $transition-duration cubic-bezier(0.8, 0, 0.2, 1) infinite;
  }
}

@keyframes slide {
  0% {
    transform: translateY(-50px);
  }
  100% {
    transform: translateY(50px);
  }
}

@keyframes escalade {
  0% {
    stroke-dasharray: 0 $path-length;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: $path-length - 1 $path-length;
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dasharray: $path-length - 1 $path-length;
    stroke-dashoffset: -($path-length - 1);
  }
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 29,008评论 1 45
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,252评论 1 92
  • 一、HTML 教程 HTML教程HTML简介HTML编辑器HTML基础HTML元素HTML属性 HTML标题HTM...
    茶茶点阅读 951评论 0 0
  • 译者:旭日云中竹链接:http://www.zcfy.cc/article/1057原文:https://medi...
    51CTO学院阅读 5,374评论 2 179
  • 我记得我曾经有过个写作的梦,是在做女孩儿的时候。 记得我曾经有个写作梦,那梦是很真实的我在做着。不论我是醒着还是睡...
    与你画夕阳阅读 222评论 0 0

友情链接更多精彩内容