本文主要介绍了纯html+css实现Element loading效果,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这是 Element UI loading 组件的效果图,看起来很酷,我们来实现一下!
分析
动画由两部分组成:
蓝色的弧线由点伸展成一个圆,又从圆收缩成一个点。
圆的父节点带着圆旋转
代码
html
<svg viewBox="25 25 50 50" class="box">
<circle cx="50" cy="50" r="20" fill="none" class="circle"></circle>
</svg>
css
默认样式
.box {
height: 200px;
width: 200px;
background: wheat;
}
.box .circle {
stroke-width: 2;
stroke: #409eff;
stroke-linecap: round;
}
添加动画效果
/* 旋转动画 */
@keyframes rotate {
to {
transform: rotate(1turn)
}
}
/* 弧线动画 */
/* 125 是圆的周长 */
@keyframes circle {
0% {
/* 状态1: 点 */
stroke-dasharray: 1 125;
stroke-dashoffset: 0;
}
50% {
/* 状态2: 圆 */
stroke-dasharray: 120, 125;
stroke-dashoffset: 0;
}
to {
/* 状态3: 点(向旋转的方向收缩) */
stroke-dasharray: 120 125;
stroke-dashoffset: -125px;
}
}
.box {
/* ...同上 */
animation: rotate 2s linear infinite;
}
.circle {
/* ...同上 */
animation: circle 2s infinite;
}
最后把背景去掉
在线代码演示 https://jsbin.com/yarufoy/edit?html,css,output
到此这篇关于纯html+css实现Element loading效果的文章就介绍到这了,更多相关html+css实现 loading内容请搜索编程学习网以前的文章,希望大家以后多多支持编程学习网!
织梦狗教程
本文标题为:纯html+css实现Element loading效果


基础教程推荐
猜你喜欢
- JavaScript垃圾回收机制(引用计数,标记清除,性能优 2022-08-31
- ajax实现数据分页查询 2023-01-31
- 纯javascript的ajax实现php异步提交表单的简单实例 2022-12-28
- 原生ajax瀑布流demo分享(必看篇) 2023-02-01
- Ajax提交表单并接收json实例代码 2023-02-13
- 解决:layUI数据表格+简单查询 2022-12-16
- AJax 把拿到的后台数据在页面中渲染的实例 2023-02-22
- 在IE中为abbr标签加样式 2022-10-16
- 关于ajax异步访问数据的问题 2023-02-23
- Unicode中的常用字母小结 2022-09-21