CSS 一鍵置灰網(wǎng)頁

有些特殊的日子需要將網(wǎng)頁置灰,比如向致敬某人、紀(jì)念某些重要的日期等。

方法1

html.gray {
  filter: grayscale(100%);
  -webkit-filter: grayscale(100%);
  -moz-filter: grayscale(100%);
  -ms-filter: grayscale(100%);
  -o-filter: grayscale(100%);
  filter: grayscale(100%);
}

方法2

  • 使用 backdrop-filter 實(shí)現(xiàn)首屏置灰遮罩
html {
  position: relative;
}
html::before {
  content: "";
  position: absolute;
  inset: 0;
  /* 保證頁面交互 */
  pointer-events: none;
  z-index: 999;
  backdrop-filter: grayscale(95%);
}

方法3

  • 借助混合模式實(shí)現(xiàn)網(wǎng)站置灰
html {
  background: #fff;
  position: relative;
}
html::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: color;
  background: rgba(0, 0, 0, 1);
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容