我在加载任何数据时在Angular代码中使用微调器。我为它创建了一个单独的组件(下面给出了必要的文件)。我的微调器看起来像这样:
现在,我需要在旋转器后面显示加载图标的同时模糊微调器后面的背景。知道怎么做到了吗?
spinner.component.ts:
import { Component } from "@angular/core";
@Component({
selector: "loading-spinner",
templateUrl: "./spinner.component.html",
styleUrls: ["./spinner.component.css"]
})
export class SpinnerComponent{
}
spinner.component.html:
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
spinner.component.css:
.spinner {
width: 50px;
height: 40px;
text-align: center;
font-size: 10px;
position: fixed;
z-index: 1500;
overflow: show;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.spinner > div {
background-color: #333;
height: 100%;
width: 6px;
display: inline-block;
-webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
animation: sk-stretchdelay 1.2s infinite ease-in-out;
}
.spinner .rect2 {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s;
}
.spinner .rect3 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
.spinner .rect4 {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
.spinner .rect5 {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s;
}
@-webkit-keyframes sk-stretchdelay {
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
20% { -webkit-transform: scaleY(1.0) }
}
@keyframes sk-stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4);
-webkit-transform: scaleY(0.4);
} 20% {
transform: scaleY(1.0);
-webkit-transform: scaleY(1.0);
}
}
答案 0 :(得分:3)
添加叠加div并与微调器同时显示。
Css将是:
.spinner_overlay {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: #fff;
opacity: 0.2;
z-index: 1000;
}
并添加
<div class="spinner_overlay"></div>
到您的模板。
这会有效!