CSS3的新滤镜属性在webkit浏览器和Firefox中得到支持。它不支持IE或Opera mini浏览器:
img {
-webkit-filter: invert(1);
filter: invert(1);
}
<img src="http://i.imgur.com/1H91A5Y.png">
filter: url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='blur'><feGaussianBlur stdDeviation='5' /></filter></svg>");
但是它并没有...有什么想法吗? - laggingreflex可以使用以下代码在大多数新浏览器中完成
.img {
-webkit-filter:invert(100%);
filter:progid:DXImageTransform.Microsoft.BasicImage(invert='1');
}
但是,如果您希望它在所有浏览器上运行,您需要使用JavaScript。类似这个代码片段将能完成任务。
function invert(){
document.getElementById("theImage").style.filter="invert(100%)";
}
And this is the
<img id="theImage" class="img-responsive" src="http://i.imgur.com/1H91A5Y.png"></img>
Now all you need to do is call invert() We do this when the image is clicked.
function invert(){
document.getElementById("theImage").style.filter="invert(100%)";
}
<h4> Click image to invert </h4>
<img id="theImage" class="img-responsive" src="http://i.imgur.com/1H91A5Y.png" onClick="invert()" ></img>
We use this on our website