

backdrop-filterbackground-sizebackground-imagebackdrop-filter属性
filter属性
二者区别
backdrop-filter作用于元素的背景(不直接作用于元素,而是通过另外一层元素来达到效果)
filter直接设置在元素身上
二者支持的滤镜对比(其实filter可以用的,backdrop-filter都可以用)
| filter | backdrop-filter | 备注 | |
|---|---|---|---|
| url | √ | √ | 获取指向SVG过滤器的URI |
| blur(模糊) | √ | √ | 高斯模糊滤镜 |
| brightness(亮度) | √ | √ | 图像明亮度的滤镜 |
| contrast(对比度) | √ | √ | 图像的对比度滤镜 |
| drop-shadow(阴影) | √ | √ | 图像的阴影滤镜 |
| grayscale(灰度) | √ | √ | 图像灰度滤镜 |
| hue-rotate(色相旋转) | √ | √ | 图像色相滤镜 |
| invert(反色) | √ | √ | 反转滤镜 |
| opacity(透明度) | √ | √ | 透明度滤镜 |
| sepia | √ | √ | 深褐色滤镜 |
| saturate(褐色) | √ | √ | 图像饱和度滤镜 |
blur和saturate属性来达到的.navbar-wrapper {
position: relative;
border-bottom: 1px solid #dcdfe6;
height: 55px;
background-image: radial-gradient(transparent 1px,#ffffff 1px);
background-size: 4px 4px;
backdrop-filter: saturate(50%) blur(4px);
top: 0;
}
background-image: radial-gradient(transparent 1px,#ffffff 1px);background-size: 4px 4px;backdrop-filter: saturate(50%) blur(4px);background-size:设置背景图片大小,这个不用多说
background-image设置背景图片的大小
所以我们如果只设置这二个值会发生什么?为了便于观看,我将background-image换为了一张具体图片,便于查看
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Documenttitle>
<style>
.wrapper {
width: 500px;
height: 300px;
background: url("../image/26.jpg")
}
.content {
width: 300px;
height: 150px;
/* background-image: radial-gradient(transparent 1px, #ffffff 1px); */
/* background-size: 4px 4px; */
/* backdrop-filter: saturate(50%) blur(4px); */
background-image: url('../image/27.jpg');
background-size: 4px 4px;
}
style>
head>
<body>
<div class="wrapper">
<div class="content">div>
div>
body>
html>
初次的时候你可能看到这个效果
是不是觉得这个点点是什么,我们放大看看
background-size尺寸,然后默认背景会铺满全部的,所以就导致这效果
background-size和background-image换为element-ui上的属性,看看会发生什么.content {
width: 300px;
height: 150px;
/* 换为element-ui官网的 */
background-image: radial-gradient(transparent 1px, #ffffff 1px);
background-size: 4px 4px;
/*backdrop-filter:saturate(50%) blur(4px); */
/* background-image: url('../image/27.jpg');
background-size: 4px 4px; */
}
backdrop-filter样式<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Documenttitle>
<style>
.wrapper {
width: 500px;
height: 300px;
background: url("../image/26.jpg")
}
.content {
width: 300px;
height: 150px;
/* 换为element-ui官网的 */
background-image: radial-gradient(transparent 1px, #ffffff 1px);
background-size: 4px 4px;
backdrop-filter:saturate(50%) blur(4px);
/* background-image: url('../image/27.jpg');
background-size: 4px 4px; */
}
style>
head>
<body>
<div class="wrapper">
<div class="content">div>
div>
body>
html>
你可以对比看看,添加backdrop-filter在这里也就多了一层朦胧的效果
你也可以扩大一点,使得A身上的B元素和A一样宽度,就成了下面这种效果
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Documenttitle>
<style>
.wrapper {
width: 500px;
height: 300px;
background: url("../image/26.jpg")
}
.content {
width: 500px;
height: 300px;
/* 换为element-ui官网的 */
background-image: radial-gradient(transparent 1px, #ffffff 1px);
background-size: 4px 4px;
backdrop-filter:saturate(50%) blur(4px);
/* background-image: url('../image/27.jpg');
background-size: 4px 4px; */
}
style>
head>
<body>
<div class="wrapper">
<div class="content">div>
div>
body>
html>
backdrop-filter来实现的,由于找不到这张图就源代码,就自己写了下~
最终完成效果


<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
*{
margin: 0;
padding: 0;
background-color: #000000;
}
/* 外层-实现居中 */
#wrapper{
width: 40%;
height: 40%;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
/* 圆点形状 */
.dot{
width: 120px;
height: 120px;
border-radius: 50%;
background-color: #00ffc6;
}
.dot-wrapper{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.dot-wrapper div:nth-of-type(1){
animation: dotLeft linear infinite 5s;
}
.dot-wrapper div:nth-of-type(2){
align-self: flex-end;
}
/* 模糊背景div */
.mask-wrapper{
width: 90%;
height: 70%;
position: absolute;
bottom: 0;
top: 0;
left: 0;
right: 0;
margin: auto;
border-radius: 10px;
background-color: rgba(255, 255, 255, .1);/* 透明背景 */
backdrop-filter: blur(5px);
box-shadow: -1px 0px rgba(255, 255, 255, .4);
color: #e9e9e9;
font-size: 26px;
}
style>
head>
<body>
<div id="wrapper">
<div class="dot-wrapper">
<div class="dot">div>
<div class="dot">div>
div>
<div class="mask-wrapper">
<div style="background-color:transparent;height: 100%;text-align: center;transform: translateY(40%);">
梦洁小站
div>
div>
div>
body>
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
*{
margin: 0;
padding: 0;
background-color: #000000;
}
/* 外层-实现居中 */
#wrapper{
width: 40%;
height: 40%;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
/* 圆点形状 */
.dot{
width: 120px;
height: 120px;
border-radius: 50%;
background-color: #00ffc6;
}
.dot-wrapper{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
@keyframes dotLeft {
0%{
transform: translate(0,0);
}
50%{
transform: translate(16px,-16px);
}
100%{
transform: translate(0,0);
}
}
.dot-wrapper div:nth-of-type(1){
animation: dotLeft linear infinite 5s;
}
@keyframes dotRight {
0%{
transform: translate(0,0);
}
50%{
transform: translate(-20px,20px);
}
100%{
transform: translate(0,0);
}
}
.dot-wrapper div:nth-of-type(2){
align-self: flex-end;
animation: dotRight linear infinite 5s;
}
@keyframes maskAni{
0%{
transform: translate(0,0);
}
25%{
transform: translate(-4px,6px);
}
50%{
transform: translate(4px,0);
}
100%{
transform: translate(0,0);
}
}
/* 模糊背景div */
.mask-wrapper{
width: 90%;
height: 70%;
position: absolute;
bottom: 0;
top: 0;
left: 0;
right: 0;
margin: auto;
border-radius: 10px;
background-color: rgba(255, 255, 255, .1);/* 透明背景 */
backdrop-filter: blur(5px);
box-shadow: -1px 0px rgba(255, 255, 255, .4);
color: #e9e9e9;
font-size: 26px;
animation: maskAni linear infinite 5s;
}
style>
head>
<body>
<div id="wrapper">
<div class="dot-wrapper">
<div class="dot">div>
<div class="dot">div>
div>
<div class="mask-wrapper">
<div style="background-color:transparent;height: 100%;text-align: center;transform: translateY(40%);">
梦洁小站
div>
div>
div>
body>
html>
