一、网站变灰 <!DOCTYPE html> <html> <head> <style> img { -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); filter: grayscale(100%); filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); filter: gray; } </style> </head> <body> <p>图片转为黑白色:</p> <img src="pineapple.jpg" alt="Pineapple" width="300" height="300"> <p><strong>注意:</strong> Internet Explorer 或 Safari 5.1 (及更早版本) 不支持该属性。</p> </body> </html> 二、图片使用高斯模糊效果: <!DOCTYPE html> <html> <head> <style> img { -webkit-filter: blur(5px); /* Chrome, Safari, Opera */ filter: blur(5px); } </style> </head> <body> <p>图片使用高斯模糊效果:</p> <img src="pineapple.jpg" alt="Pineapple" width="300" height="300"> <p><strong>注意:</strong> Internet Explorer 不支持 filter 属性。</p> </body> </html>