我有带有动态背景图像的垫卡,我需要模糊此图像
<mat-card [ngStyle]='{backgroundImage: backgroundImage}'>
<mat-card-title>My card</mat-card-title>
<mat-card-content>Card Content</mat-card-content>
</mat-card>
我的 CSS
mat-card {
background-repeat: no-repeat;
background-position: 50% 0;
background-size: 100% 100%;
/* this blure all card */
filter: blur(8px);
-webkit-filter: blur(8px);
}
我有什么: 示例我有 什么我需要什么: 示例我需要什么 这是我添加此代码后得到的:
mat-card:before {
content: ' ';
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.2;
background-image: url('img url');
background-repeat: no-repeat;
background-position: 50% 0;
background-size: 100% 100%;
filter: blur(10px);
-webkit-filter: blur(10px);
}
但是这种方法不适合我,因为伪元素不是 DOM 树的一部分,因此不会暴露任何可用于与它们交互的 DOM API