当前位置:网站首页>骨架效果 之高级渐变,适用图片等待时
骨架效果 之高级渐变,适用图片等待时
2022-08-02 03:22:00 【suzhiwei_boke】
大致步骤:
- 需要一个组件,做占位使用。这个占位组件有个专业术语:骨架屏组件。
- 暴露一些属性:高,宽,背景,是否有闪动画。
- 这是一个公用组件,需要全局注册,将来这样的组件建议再vue插件中定义。
- 使用组件完成左侧分类骨架效果。
<template>
<div class="xtx-skeleton" :style="{width,height}" :class="{shan:animated}">
<!-- 1 盒子-->
<div class="block" :style="{backgroundColor:bg}"></div>
<!-- 2 闪效果 xtx-skeleton 伪元素 --->
</div>
</template>
<script>
export default {
name: 'XtxSkeleton',
// 使用的时候需要动态设置 高度,宽度,背景颜色,是否闪下
props: {
bg: {
type: String,
default: '#eee'
},
width: {
type: String,
default: '100px'
},
height: {
type: String,
default: '30px'
},
animated: {
type: Boolean,
default: true
}
}
}
</script>
<style scoped lang="less">
.xtx-skeleton {
display: inline-block;
position: relative;
overflow: hidden;
vertical-align: middle;//该元素所在行的基线的垂直对齐
.block {
width: 100%;
height: 100%;
border-radius: 2px;
}
}
.shan {
&::after {
content: "";
position: absolute;
animation: shan 1.5s ease 0s infinite; //动画 keyframe名称 动画所花费的时间 速度曲线(linear 匀速 ease加速度) 之前的延迟
top: 0;
width: 50%;
height: 100%;
background: linear-gradient(
to left,
rgba(255, 255, 255, 0) 0,
rgba(255, 255, 255, 0.3) 50%,
rgba(255, 255, 255, 0) 100%
);//渐变
transform: skewX(-45deg);//倾斜
}
}
// 关键帧
@keyframes shan {
0% {
left: -100%;
}
100% {
left: 120%;
}
}
</style>
边栏推荐
- 【面试】失败的一次面试
- SSM整合
- PowerManagerService灭屏超时流程
- ImportError: libGL.so.1: cannot open shared object file: No such file or directory
- IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
- 删库后!除了跑路还能干什么?
- @Accessors 注解详解
- [Learning Records of Boxue Valley] Super summary, share with heart | Software Testing Interface Testing Basics
- Redis笔记进阶篇:万字长文-整理Redis,各种知识点,建议收藏
- Scientific research reagent DMPE-PEG-Mal dimyristoylphosphatidylethanolamine-polyethylene glycol-maleimide
猜你喜欢
Cloud server installation and deployment of Nacos 2.0.4 version
磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
【装机】老毛桃的安装及使用
Debian 10 NTP Service Configuration
MySQL中字符串比较大小(日期字符串比较问题)
querystring模块
subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.
MySQL中JOIN的用法
@Autowired与@Resource区别
磷脂-聚乙二醇-靶向新生血管靶向肽APRPG,DSPE-PEG-APRPG
随机推荐
Mysql8.0安装教程
C语言 结构体定义方法
The difference between the knowledge question and answer session with the knowledge
C语言中关于2的n次方求值问题(移位运算)
MySQL分页查询的5种方法
Redis简单学习笔记
排序学习笔记(二)堆排序
__dirname
知识问答与知识会话的区别
Basic usage of Monaco Editor
第一篇博客
APK的安装过程分析 PMS包管理器
Debian 10 NTP Service Configuration
AttributeError: Can't get attribute 'SPPF' on
Amazon sellers how to improve the conversion
@Accessors 注解详解
啃瓜记录第一天
【深度学习】从LeNet-5识别手写数字入门深度学习
ssm various configuration templates
3 minutes to take you to understand WeChat applet development