前端页面全局变灰,兼容IE、Chrome

设置页面全局变灰,兼容IE、Chrome

在js文件中写入以下方法并调用

setGlobalBackgroundGray()
function setGlobalBackgroundGray(){
  var style = document.createElement("style");
  style.type = "text/css";
  style.appendChild(document.createTextNode("html{filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter:grayscale(100%);}"));
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(style);
}

或者在css中设置

<style>
  html {
    filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
    -webkit-filter:grayscale(100%);
  }
</style>

感谢阅读 友情链接

发布了8 篇原创文章 · 获赞 27 · 访问量 2111

猜你喜欢

转载自blog.csdn.net/weixin_45612438/article/details/105297177