工作时,上图白色光影的的动态气泡光点动态显示。
本来规划canvas 绘制,或者threejs绘制,但是需要js添加计时器,做动态绘制气泡
由于页面大量出现这种动图,考虑性能问题用css3 实现 具体代码如下所示
<template>
<div class="decorate">
<div class="bubble-Box">
<span class="bubble1 bubble"></span>
<span class="bubble2 bubble"></span>
<span class="bubble3 bubble"></span>
<span class="bubble4 bubble"></span>
<span class="bubble5 bubble"></span>
<span class="bubble6 bubble"></span>
<span class="bubble7 bubble"></span>
<span class="bubble8 bubble"></span>
</div>
<img src="@/assets/images/normal.png" alt="" />
</div>
</template>
<script setup lang="ts">
</script>
<style scoped lang="scss">
.decorate {
width: 44px;
height: 109px;
position: relative;
img {
width: 44px;
height: 109px;
}
}
.bubble-Box {
width: 16px;
height: 24px;
position: absolute;
left: 14px;
top: 5px;
// overflow: hidden;
// background: #f0f;
}
.bubble{
width: 10px;
height: 10px;
transform: scale(0.2);
border-radius: 50%;
background-color: rgb(255, 255, 255,0);
position: absolute;
bottom: 1px;
left: 1px;
}
.bubble1{
animation: decorateUp 3s 2s linear infinite;
}
.bubble2{
animation: decorateUprt 3s 2s cubic-bezier(0.075, 0.42, 0.85, 1) infinite;
}
.bubble3{
animation: decorateUp 3s 2s linear infinite;
}
.bubble4{
animation: decorateUp 3s 3s linear infinite;
}
.bubble5{
animation: decorateUprt 3s 3s cubic-bezier(0.075, 0.42, 0.85, 1) infinite;
}
.bubble6{
animation: decorateUp 3s 3s linear infinite;
}
.bubble7{
animation: decorateUp 3s 1s linear infinite;
}
.bubble8{
animation: decorateUprt 3s 1s cubic-bezier(0.075, 0.22, 0.65, 1) infinite;
}
@keyframes decorateUp {
0%{
left: 0px;
bottom: -5px;
background-color: rgb(255, 255, 255,0.5);
}
100% {
left: 8px;
bottom: 34px;
background-color: rgb(255, 255, 250, 0);
}
}
@keyframes decorateUprt {
0%{
left: 8px;
bottom: -5px;
background-color: rgb(255, 255, 255,0.5);
}
100% {
left: 0px;
bottom: 34px;
background-color: rgb(255, 255, 250, 0);
}
}
</style>