这是我参与8月更文挑战的第28天,活动详情查看:8月更文挑战
作者:battleKing
仓库:Github、CodePen
博客:CSDN、掘金
反馈邮箱:myh19970701@foxmail.com
特别声明:原创不易,未经授权不得转载或抄袭,如需转载可联系笔者授权
背景
在用户心目中,优秀的应用、工具、网站都应该是制作精良且能快速响应他们需求的产品。以前我在发布一款产品的第一版时,登录验证的 loading...
延迟是 2-3秒
,结果当天反馈邮箱就被用户挤爆了,大部分用户都认为这几秒是一个界面突然卡住是 软件BUG
,其实只是我们 验证登录信息
而已,所以如果没有 加载动画
告知用户我们在验证登录信息而只是让软件卡住不动的话,这是一种 非常不好的用户体验
,虽然早期用户可能会给你的产品第二次机会,但绝大多数人对这款产品失去信息,不再使用,导致用户大量流失
。
解决方案:使用 加载动画
,提供 即使反馈
,减少用户焦虑
加载动画分类:进度条加载动画
,无限循环加载动画
和 骨架图加载动画
优秀的加载动画特征
- 核心是
减少动画时间
- 给出
具体时间
- 告诉用户
为什么需要等待
- 让等待的过程不那么让人无聊
使用有趣的动画
- 减少用户等待时间的心理感知
色彩
、某个相关知识
、某条产品操作教学
- 透传公司品牌形象
公司理念
、公司价值观
、公司的标志吉祥物
最终效果
一、添加 HTML 文件
- 最外层创建一个类名为
lds-roller
的div
- 里面放置数个
div
<div class="lds-roller">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
二、添加 CSS 文件
先初始化页面
- 设置
*
为box-sizing: border-box
- 设置
body
来使整个项目居中
* {
box-sizing: border-box;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background: #eaac83;
}
主要的 CSS 代码
.lds-roller {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-roller div {
animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
transform-origin: 40px 40px;
}
.lds-roller div:after {
content: " ";
display: block;
position: absolute;
width: 7px;
height: 7px;
border-radius: 50%;
background: #fff;
margin: -4px 0 0 -4px;
}
.lds-roller div:nth-child(1) {
animation-delay: -0.036s;
}
.lds-roller div:nth-child(1):after {
top: 63px;
left: 63px;
}
.lds-roller div:nth-child(2) {
animation-delay: -0.072s;
}
.lds-roller div:nth-child(2):after {
top: 68px;
left: 56px;
}
.lds-roller div:nth-child(3) {
animation-delay: -0.108s;
}
.lds-roller div:nth-child(3):after {
top: 71px;
left: 48px;
}
.lds-roller div:nth-child(4) {
animation-delay: -0.144s;
}
.lds-roller div:nth-child(4):after {
top: 72px;
left: 40px;
}
.lds-roller div:nth-child(5) {
animation-delay: -0.18s;
}
.lds-roller div:nth-child(5):after {
top: 71px;
left: 32px;
}
.lds-roller div:nth-child(6) {
animation-delay: -0.216s;
}
.lds-roller div:nth-child(6):after {
top: 68px;
left: 24px;
}
.lds-roller div:nth-child(7) {
animation-delay: -0.252s;
}
.lds-roller div:nth-child(7):after {
top: 63px;
left: 17px;
}
.lds-roller div:nth-child(8) {
animation-delay: -0.288s;
}
.lds-roller div:nth-child(8):after {
top: 56px;
left: 12px;
}
@keyframes lds-roller {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
❤️ 感谢大家
如果本文对你有帮助,就点个赞支持下吧,你的「赞」是我创作的动力。
如果你喜欢这篇文章的话,可以「点赞」 + 「收藏」 + 「转发」 给更多朋友。