svg实现简单的loading

html

<div class="loader">
    <svg width="100" height="100">
        <polygon class="triangle" fill="none" stroke="#7eccd8" stroke-width="4" points="50,1 99,99 1,99"/>
    </svg>
</div>

css

//设置实线和虚线的宽度
stroke-dasharray: 50 30;
//引用dash动画,动画时长2.5s
-webkit-animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;

.loader {
    width: 100px;
    height: 100px;
    position:absolute;
    right:0;
    left:0;
    margin:auto;
    top:0;
    bottom:0;
    z-index:3
}
.loader .triangle {
    stroke-dasharray: 50 30;
    -webkit-animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;
    -moz-animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;
    -ms-animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;
    -o-animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite;
    animation:dash 2.5s cubic-bezier(0.35, 0.04, 0.63, 0.95) infinite
}]
//命名dash,动画写划线的距离
@-webkit-keyframes dash {
    to {
        stroke-dashoffset:500
    }
}
@-moz-keyframes dash {
    to {
        stroke-dashoffset:500
    }
}
@-ms-keyframes dash {
    to {
        stroke-dashoffset:500
    }
}
@-o-keyframes dash {
    to {
        stroke-dashoffset:500
    }
}
@keyframes dash {
    to {
        stroke-dashoffset:500
    }
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 6,857评论 0 11
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 5,858评论 0 2
  • 晚上月月早早吃过晚饭,姥姥带着,骑着三轮车到俱乐部卖灯笼。妈妈下班晚,吃过饭后,和爸爸,妹妹一起去看月月卖灯笼。 ...
    刘慢慢_9744阅读 3,388评论 0 0
  • 银河迢迢挂鹊桥 牛郎织女相拥抱 真爱又岂在暮暮朝朝
    墨舞竹阅读 3,624评论 20 10
  • 有一个女人,像妈妈一样爱我 文/水灵儿 正在午睡时,门铃突然响起,打开门竟然是姐姐,满头大汗的大包小包提了一大堆东...
    Rrl水灵儿阅读 5,382评论 0 0