- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 轉換
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z-index
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪輯
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - 全部
- CSS - 內嵌
- CSS - 隔離
- CSS - 滾動溢位
- CSS - Justify Items
- CSS - Justify Self
- CSS - 製表符大小
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大塊級尺寸
- CSS - 最小塊級尺寸
- CSS - 混合模式
- CSS - 最大內聯尺寸
- CSS - 最小內聯尺寸
- CSS - 偏移量
- CSS - 重音顏色
- CSS - 使用者選擇
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 圖層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多重背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2d 變換
- CSS - 3d 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - backdrop-filter 屬性
CSS backdrop-filter 屬性用於為元素後面的區域(即元素的背景)新增圖形效果。由於此屬性添加了諸如模糊之類的效果,因此元素需要完全或部分透明才能使效果可見。
語法
backdrop-filter: none | filter | initial | inherit;
屬性值
| 值 | 描述 |
|---|---|
| none | 不對元素的背面應用任何濾鏡。預設值。 |
| filter | 一個用空格分隔的濾鏡函式列表,例如blur()、brightness()、contrast()、drop-shadow()、grayscale()、hue-rotate()、invert()、opacity()、sepia()、saturate() 或指向將應用於背景的 SVG 濾鏡的 URL。 |
| initial | 將屬性設定為其初始值。 |
| inherit | 從父元素繼承屬性。 |
CSS 背景濾鏡屬性示例
下面描述了具有不同值的backdrop-filter 屬性的示例。
無濾鏡背景
要避免對元素的背景應用濾鏡,我們使用none 值。以下示例中顯示了這一點。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.nofilter-box {
-webkit-backdrop-filter: none;
backdrop-filter: none;
color: white;
}
</style>
</head>
<body>
<h1>CSS backdrop-filter property</h1>
<div class="background-img">
<div class="nofilter-box">
<p>backdrop-filter: none</p>
</div>
</div>
</body>
</html>
模糊背景
要對元素的背景應用模糊效果,我們使用blur 濾鏡。以下示例中顯示了這一點。使用了 15px 的模糊。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.blur-box {
-webkit-backdrop-filter: blur(15px);
backdrop-filter: blur(15px);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="blur-box">
<p>backdrop-filter: blur(15px)</p>
</div>
</div>
</body>
</html>
背景亮度
要調整元素背景的亮度,使用brightness 濾鏡。以下示例中顯示了這一點。使用了 50% 的亮度。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.bright-box {
-webkit-backdrop-filter: brightness(50%);
backdrop-filter: brightness(50%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="bright-box">
<p>backdrop-filter: brightness(50%)</p>
</div>
</div>
</body>
</html>
背景暗度
要調整元素背景的對比度,我們使用contrast 濾鏡。以下示例中顯示了這一點。使用了 10% 的對比度。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.contrast-box {
-webkit-backdrop-filter: contrast(10%);
backdrop-filter: contrast(10%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="contrast-box">
<p>backdrop-filter: contrast(10%)</p>
</div>
</div>
</body>
</html>
灰度背景
要為元素的背景新增灰度效果,我們使用grayscale 濾鏡。以下示例中顯示了這一點。使用了 70% 的灰度值。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.gray-box {
-webkit-backdrop-filter: grayscale(70%);
backdrop-filter: grayscale(70%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="gray-box">
<p>backdrop-filter: grayscale(70%)</p>
</div>
</div>
</body>
</html>
旋轉背景顏色
要為元素的背景新增色相旋轉效果,我們使用hue-rotate 濾鏡。它透過圍繞色輪旋轉來更改背景的顏色。指定的角度決定旋轉方向。以下示例中顯示了這一點。使用了 120 度的角度。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.hue-box {
-webkit-backdrop-filter: hue-rotate(120deg);
backdrop-filter: hue-rotate(120deg);
color: white;
}
</style>
</head>
<body>
<h1>CSS backdrop-filter property</h1>
<div class="background-img">
<div class="hue-box">
<p>backdrop-filter: hue-rotate(120deg)</p>
</div>
</div>
</body>
</html>
反轉背景顏色
要為元素的背景新增反轉效果,我們使用invert 濾鏡。它反轉背景的顏色併產生負片效果。以下示例中顯示了這一點。為反轉濾鏡提供了 70% 的值。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.invert-box {
background-color: rgba(255, 255, 255, 0.4);
-webkit-backdrop-filter: invert(70%);
backdrop-filter: invert(70%);
color: white;
}
</style>
</head>
<body>
<h1>CSS backdrop-filter property</h1>
<div class="background-img">
<div class="invert-box">
<p>backdrop-filter: invert(70%)</p>
</div>
</div>
</body>
</html>
背景透明度
要調整元素背景的透明度效果,我們使用opacity 濾鏡。以下示例中顯示了這一點。使用了 10% 的不透明度。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.opacity-box {
-webkit-backdrop-filter: opacity(10%);
backdrop-filter: opacity(10%);
color: white;
}
</style>
</head>
<body>
<h1>CSS backdrop-filter property</h1>
<div class="background-img">
<div class="opacity-box">
<p>backdrop-filter: opacity(10%)</p>
</div>
</div>
</body>
</html>
暖色背景
要為背景新增模擬溫暖的棕褐色色調,從而產生舊照片效果,我們使用sepia 濾鏡。以下示例中顯示了這一點。為 sepia 濾鏡提供了 90% 的值。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.sepia-box {
-webkit-backdrop-filter: sepia(90%);
backdrop-filter: sepia(90%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="sepia-box">
<p>backdrop-filter: sepia(90%)</p>
</div>
</div>
</body>
</html>
背景顏色強度
要為元素的背景新增飽和度效果,該效果調整顏色的強度,我們使用
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.saturate-box {
-webkit-backdrop-filter: saturate(180%);
backdrop-filter: saturate(180%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="saturate-box">
<p>backdrop-filter: saturate(180%)</p>
</div>
</div>
</body>
</html>
對背景應用多個濾鏡效果
我們還可以同時使用多個濾鏡。在以下示例中,使用了blur 和grayscale 濾鏡。使用了 2px 的模糊和 70% 的灰度值。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.background-img {
background: url(/css/images/white-flower.jpg) no-repeat center;
background-size: cover;
align-items: center;
display: flex;
justify-content: center;
padding: 20%;
}
.multi-box {
-webkit-backdrop-filter: blur(2px) grayscale(70%);
backdrop-filter: blur(2px) grayscale(70%);
color: white;
}
</style>
</head>
<body>
<h1> CSS backdrop-filter property</h1>
<div class="background-img">
<div class="multi-box">
<p>backdrop-filter: blur(2px) grayscale(70%)</p>
</div>
</div>
</body>
</html>
支援的瀏覽器
| 屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| backdrop-filter | 76.0 | 17.0 | 70.0 | 9.0 | 63.0 |




