Tailwind CSS - 背景灰度 (Backdrop Grayscale)



Tailwind CSS 背景灰度 (Backdrop Grayscale) 是一個實用程式類,用於將背景灰度濾鏡應用於元素。

Tailwind CSS 背景灰度類

以下是用於有效應用背景灰度濾鏡的Tailwind CSS 背景灰度類列表。

類名 CSS 屬性
backdrop-grayscale-0 filter: backdrop-grayscale(0);
backdrop-grayscale filter: backdrop-grayscale(100%);

Tailwind CSS 灰度類的功能

  • backdrop-grayscale-0: 此類用於從元素中移除背景灰度濾鏡。
  • backdrop-grayscale: 此類用於將背景灰度濾鏡應用於元素。

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 Grayscale 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-grayscale-0 absolute w-36 h-36
                        border-2 border-green-500 top-4 left-4 
                        text-lime-100 font-bold py-12 text-center">
                Backdrop-grayscale-0
            </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-grayscale absolute w-36 h-36
                        border-2 border-green-500 top-4 left-4 
                        text-lime-100 font-bold py-12 text-center">
                Backdrop-grayscale
            </div>
        </div>
    </div>
</body>

</html>
廣告