源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>编程字典</title> <style> img { opacity: 0.5; filter: alpha(opacity=50); /* For IE8 and earlier */ } img:hover { opacity: 1.0; filter: alpha(opacity=100); /* For IE8 and earlier */ } </style> </head> <body> <h1>图像的透明度</h1> <p>opacity 属性经常和:hover选择器一起使用,鼠标经过改变透明度</p> <img src="img_forest.jpg" alt="Forest" width="170" height="100"> <img src="img_mountains.jpg" alt="Mountains" width="170" height="100"> <img src="img_fjords.jpg" alt="Fjords" width="170" height="100"> <p><b>注意:</b> 在IE里面, 针对 :hover 选择器 必须添加!DOCTYPE </p> </body> </html>
运行结果