加入css樣式
html{
filter: grayscale(100%);
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
-moz-filter: grayscale(100%); -filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: url("data:image/svg+xml;utf8,#grayscale"); /* Firefox */
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
filter: gray; /* IE6-9 */
}
filter: gray; /* IE6-9 */
html標籤中加入以下程式碼
<span style="color: #0000ff;"><</span><span style="color: #800000;">html </span><span style="color: #ff0000;">style</span><span style="color: #0000ff;">="filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter: grayscale(100%);"</span><span style="color: #0000ff;">></span>
ie 10 如果在必須變灰色的情況下,可以嘗試使用grayscale.js