首頁  >  文章  >  web前端  >  css實作簡單背景模糊的方法(程式碼範例)

css實作簡單背景模糊的方法(程式碼範例)

青灯夜游
青灯夜游轉載
2018-10-25 16:16:112533瀏覽

這篇文章帶給大家的內容是介紹css實作簡單背景模糊的方法(程式碼範例)。有一定的參考價值,有需要的朋友可以參考一下,希望對你們有幫助。

使用filter屬性來設定模糊值

#效果:

css樣式:

<style type="text/css">
        .cover {
            width: 600px;
            height: 300px;
            position: relative;
            text-align: center;
            line-height: 300px;
            color: #fff;
            margin: 20px auto;
        }
        
        .cover::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 600px;
            height: 300px;
            background: transparent url(Images/picture/5.jpg) center center no-repeat;
            filter: blur(8px);
            z-index: -1;
            background-size: cover;
        }
    </style>

HTML結構:

<body>
    <p class="cover">
        <h2>背景模糊,文字清晰显示</h2>
    </p>
</body>

以上是css實作簡單背景模糊的方法(程式碼範例)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:cnblogs.com。如有侵權,請聯絡admin@php.cn刪除