Tailwind CSS - 背景对比



Tailwind CSS 背景对比 是一个实用程序类,用于将背景对比滤镜应用于元素。

Tailwind CSS 背景对比类

以下是用于有效应用背景对比滤镜的 Tailwind CSS 背景对比 类的列表。

CSS 属性
backdrop-contrast-0 backdrop-filter: contrast(0);
backdrop-contrast-50 backdrop-filter: contrast(.5);
backdrop-contrast-75 backdrop-filter: contrast(.75);
backdrop-contrast-100 backdrop-filter: contrast(1);
backdrop-contrast-125 backdrop-filter: contrast(1.25);
backdrop-contrast-150 backdrop-filter: contrast(1.5);
backdrop-contrast-200 backdrop-filter: contrast(2);

Tailwind CSS 背景对比类的功能

  • backdrop-contrast-*: 类用于有效调整元素的背景对比度。{*} 在此处指定可以根据需要设置的不同对比度值。

Tailwind CSS 背景对比类示例

以下示例说明了 Tailwind CSS 背景对比类的不同可见性和实用程序。

示例

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="p-8">
    <h2 class="text-2xl font-bold mb-3">
        Tailwind CSS Backdrop Contrast Classes
    </h2>
    <div class="flex gap-3 flex-wrap ">

        <div class="relative w-44 h-44">
            <img class="object-cover w-full h-full" 
                    src=
"/javascript/images/javascript.jpg" 
                    alt="Image">
            <div class="backdrop-contrast-50 absolute w-36 h-36
                        border-2 border-green-500 top-4 left-4 
                        text-red-600 font-bold py-12 text-center">
                Backdrop-contrast-50
            </div>
        </div>
        
        <div class="relative w-44 h-44 ">
            <img class="object-cover w-full h-full" 
                    src=
"/javascript/images/javascript.jpg" 
                    alt="Image">
            <div class="backdrop-contrast-75 absolute w-36 h-36
                        border-2 border-green-500 top-4 left-4 
                        text-red-600 font-bold py-12 text-center">
                Backdrop-contrast-75
            </div>
        </div>
        
        <div class="relative w-44 h-44 ">
            <img class="object-cover w-full h-full" 
                    src=
"/javascript/images/javascript.jpg" 
                    alt="Image">
            <div class="backdrop-contrast-100 absolute w-36 h-36 
                        border-2 border-green-500 top-4 left-4 
                        text-red-600 font-bold py-12 text-center">
                Backdrop-contrast-100
            </div>
        </div>
        
        <div class="relative w-44 h-44 ">
            <img class="object-cover w-full h-full" 
                    src=
"/javascript/images/javascript.jpg" 
                    alt="Image">
            <div class="backdrop-contrast-200 absolute w-36 h-36 
                        border-2 border-green-500 top-4 left-4 
                        text-red-600 font-bold py-12 text-center">
                Backdrop-contrast-200
            </div>
        </div>
    </div>
</body>

</html>
广告