当前位置:网站首页>骨架效果 之高级渐变,适用图片等待时
骨架效果 之高级渐变,适用图片等待时
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>
边栏推荐
- 化学试剂磷脂-聚乙二醇-羟基,DSPE-PEG-OH,DSPE-PEG-Hydroxyl,MW:5000
- Chapter 10 Clustering
- 磷脂-聚乙二醇-酰肼,DSPE-PEG-Hydrazide,DSPE-PEG-HZ,MW:5000
- Deveco studio Hongmeng app access network detailed process (js)
- np.unique() function
- C语言 void和void *(无类型指针)
- getattr() function analysis
- Phospholipid-polyethylene glycol-azide, DSPE-PEG-Azide, DSPE-PEG-N3, MW: 5000
- 知识问答与知识会话的区别
- APK的安装过程分析 PMS包管理器
猜你喜欢
Debian 10 NTP Service Configuration
C语言入门小游戏—三子棋
PCL—point cloud data segmentation
科研试剂DMPE-PEG-Mal 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
MySQL分库分表
Phospholipid-polyethylene glycol-azide, DSPE-PEG-Azide, DSPE-PEG-N3, MW: 5000
Deveco studio 鸿蒙app访问网络详细过程(js)
第一篇博客
@Autowired与@Resource区别
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the index ing argu
随机推荐
@Autowired与@Resource区别
APK的安装过程分析 PMS包管理器
广州华为面试总结
Week 7 Review
C语言 结构体定义方法
Phospholipid-polyethylene glycol-thiol, DSPE-PEG-Thiol, DSPE-PEG-SH, MW: 5000
最新,每天填坑,Jeston TX1 精卫填坑,第一步:刷机
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
Mysql8.0安装教程
我的两周年创作纪念日
【我的创作纪念日】 3周年
AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
知识问答与知识会话的区别
A senior test engineer asked me these questions as soon as the interview came
getattr() function analysis
debian 10 nat 与路由转发
Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000
MySQL分库分表
语义分割标签即像素值的巨坑,transforms.ToTensor()的错误使用
docker 安装 sqlserver中的坑点