backdrop-filter
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
**backdrop-filter
** CSS 属性允许您对元素后面的区域应用图形效果,例如模糊或颜色偏移。由于它应用于元素**后面**的所有内容,因此要看到效果,元素或其背景需要是透明或部分透明的。
试一试
语法
css
/* Keyword value */
backdrop-filter: none;
/* URL to SVG filter */
backdrop-filter: url(commonfilters.svg#filter);
/* <filter-function> values */
backdrop-filter: blur(2px);
backdrop-filter: brightness(60%);
backdrop-filter: contrast(40%);
backdrop-filter: drop-shadow(4px 4px 10px blue);
backdrop-filter: grayscale(30%);
backdrop-filter: hue-rotate(120deg);
backdrop-filter: invert(70%);
backdrop-filter: opacity(20%);
backdrop-filter: sepia(90%);
backdrop-filter: saturate(80%);
/* Multiple filters */
backdrop-filter: url(filters.svg#filter) blur(4px) saturate(150%);
/* Global values */
backdrop-filter: inherit;
backdrop-filter: initial;
backdrop-filter: revert;
backdrop-filter: revert-layer;
backdrop-filter: unset;
Values
none
-
不应用任何滤镜到背景。
<filter-function-list>
-
一个空格分隔的
<filter-function>
列表或 SVG 滤镜,它将应用于背景。CSS<filter-function>
包括blur()
、brightness()
、contrast()
、drop-shadow()
、grayscale()
、hue-rotate()
、invert()
、opacity()
、saturate()
和sepia()
。
正式定义
Initial value | none |
---|---|
Applies to | 所有元素;在 SVG 中,它应用于容器元素,不包括 <defs> 元素和所有图形元素 |
Inherited | no |
Computed value | as specified |
Animation type | 一个 滤镜函数列表 |
正式语法
backdrop-filter =
none |
<filter-value-list>
<filter-value-list> =
[ <filter-function> | <url> ]+
<filter-function> =
<blur()> |
<brightness()> |
<contrast()> |
<drop-shadow()> |
<grayscale()> |
<hue-rotate()> |
<invert()> |
<opacity()> |
<sepia()> |
<saturate()>
<url> =
<url()> |
<src()>
<blur()> =
blur( <length>? )
<brightness()> =
brightness( [ <number> | <percentage> ]? )
<contrast()> =
contrast( [ <number> | <percentage> ]? )
<drop-shadow()> =
drop-shadow( [ <color>? && <length>{2,3} ] )
<grayscale()> =
grayscale( [ <number> | <percentage> ]? )
<hue-rotate()> =
hue-rotate( [ <angle> | <zero> ]? )
<invert()> =
invert( [ <number> | <percentage> ]? )
<opacity()> =
opacity( [ <number> | <percentage> ]? )
<sepia()> =
sepia( [ <number> | <percentage> ]? )
<saturate()> =
saturate( [ <number> | <percentage> ]? )
<url()> =
url( <string> <url-modifier>* ) |
<url-token>
<src()> =
src( <string> <url-modifier>* )
示例
CSS
css
.box {
background-color: rgb(255 255 255 / 30%);
backdrop-filter: blur(10px);
}
body {
background-image: url("anemones.jpg");
}
HTML
html
<div class="container">
<div class="box">
<p>backdrop-filter: blur(10px)</p>
</div>
</div>
Result
规范
Specification |
---|
Filter Effects Module Level 2 # BackdropFilterProperty |
浏览器兼容性
BCD 表格仅在浏览器中加载