当前位置:网站首页>骨架效果 之高级渐变,适用图片等待时
骨架效果 之高级渐变,适用图片等待时
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>
边栏推荐
猜你喜欢

Phospholipid-polyethylene glycol-hydrazide, DSPE-PEG-Hydrazide, DSPE-PEG-HZ, MW: 5000

【装机】老毛桃的安装及使用

STM32 map文件解析

【深度学习】从LeNet-5识别手写数字入门深度学习

MySQL分区表详解

@Accessors 注解详解

一个结构体 = 另一个结构体(同类型结构体之间可直接赋值操作)

ThunderBirde无法登录问题、pycharm调试一直收集数据、RuntimeError: CUDA error: device-side assert triggered等疑难杂症解决

querystring模块

MySQL中JOIN的用法
随机推荐
【 application 】 life many years of operations, what turned scored 12 k + annual bonus salary?
MySQL分组后排序
基本运算符
Debian 10 NTP 服务配置
PCL—点云数据分割
API 低代码开发:接口大师,一套开发、管理和提供接口的产品框架
MySQL中JOIN的用法
PCL—point cloud data segmentation
The @autowired distinguished from @ the Resource
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
Basic usage of Monaco Editor
Problems when yolov5 calls ip camera
@DateTimeFormat注解
Detailed explanation of the usage of exists in mysql
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine supply, MW: 5000
mysql卸载详细教程
@Accessors 注解详解
Mysql8.0安装教程
Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000
UserWarning:火炬。meshgrid:在以后的版本中,它将被要求通过索引ing argu