源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> img { opacity:0.4; filter:alpha(opacity=40); /* 適用 IE8 及其更早版本 */ } img:hover { opacity:1.0; filter:alpha(opacity=100); /* 適用 IE8 及其更早版本 */ } </style> </head> <body> <h1>圖片透明度</h1> <p>opacity 屬性通常與 :hover 選擇器一起使用,在鼠標移動到圖片上後改變圖片的透明度:</p> <img src="/images/logo.png" width="150" height="113" alt="klematis"> <img src="/images/logo.png" width="150" height="113" alt="klematis"> <p><b>注意:</b>在 IE 中必須聲明 <!DOCTYPE> 才能保證 :hover 選擇器能夠有傚。</p> </body> </html>
運行結果