css中的滤镜亮度功能在Edge,IE 11和Firefox上不起作用

时间:2017-11-16 15:31:27

标签: javascript html css

在移动版中,我无法使用CSS中的过滤器属性将徽标黑色的颜色更改为白色。它适用于Chrome,但不适用于IE v11,Firefox和Edge。甚至filter属性也支持所有浏览器?我也试过javascript使它工作 - 没有成功。我不确定body标签中的onload函数是个好主意吗?

JSFIDDLE

CSS

-webkit-filter: brightness(0) invert() !important;
-ms-filter: brightness(0) invert() !important;
-moz-filter: brightness(0) invert() !important;
-o-filter: brightness(0) invert() !important;
filter: brightness(0) invert() !important;

HTML

<div class="header">
    <a href="http://www.svrs.com"><img src="imgs/logo-svrs.png" class="logo-svrs" alt="Sorenson VRS"></a>
</div>

的Javascript

<script>
  function myFunction() {
    document.getElementById("logo").style.filter = "brightness(300%)";
    document.getElementById("logo").style.WebkitFilter = "brightness(300%)"; 
    document.getElementById("logo").style.msfilter = "brightness(300%)";
    document.getElementById("logo").style.mozFilter = "brightness(300%)";
    document.getElementById("logo").style.oFilter = "brightness(300%)"; 
  }
</script>

0 个答案:

没有答案