backdrop-filter: contrast()

Các tiện ích để áp dụng bộ lọc backdrop contrast cho một phần tử.

ClassStyles
backdrop-contrast-<number>
backdrop-filter: contrast(<number>%);
backdrop-contrast-(<custom-property>)
backdrop-filter: contrast(var(<custom-property>));
backdrop-contrast-[<value>]
backdrop-filter: contrast(<value>);

Ví dụ

Ví dụ cơ bản

Sử dụng các tiện ích như backdrop-contrast-50backdrop-contrast-100 để kiểm soát độ tương phản backdrop của một phần tử:

backdrop-contrast-50

backdrop-contrast-200

<div class="bg-[url(/img/mountains.jpg)]">  <div class="bg-white/30 backdrop-contrast-50 ..."></div></div><div class="bg-[url(/img/mountains.jpg)]">  <div class="bg-white/30 backdrop-contrast-200 ..."></div></div>

Sử dụng giá trị tùy chỉnh

Use the backdrop-contrast-[<value>] syntax to set the backdrop contrast based on a completely custom value:

<div class="backdrop-contrast-[.25] ...">  <!-- ... --></div>

For CSS variables, you can also use the backdrop-contrast-(<custom-property>) syntax:

<div class="backdrop-contrast-(--my-backdrop-contrast) ...">  <!-- ... --></div>

This is just a shorthand for backdrop-contrast-[var(<custom-property>)] that adds the var() function for you automatically.

Responsive design

Prefix a backdrop-filter: contrast() utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="backdrop-contrast-125 md:backdrop-contrast-150 ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Chính sách thương hiệu