css我爱编程

css使图片变透明

2018-06-11  本文已影响5人  Lia代码猪崽

opacity属性,范围0~1,0完全透明看不见,1就是实在的一点都不透明。
filter:alpha属性(ie8之前的版本支持),范围0~100

<!DOCTYPE html>
<html>
<head>
<style>
img
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
img:hover
{
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */
}
</style>
</head>
<body>

<h1>图像透明度</h1>

<img src="/i/tulip_peach_blossom_w_s.jpg" alt="Peach Blossom" />

<p><b>注释:</b>在 IE 中,必须添加 <!DOCTYPE>,这样才能将 :hover 选择器用于除了 <a> 之外的其它元素。</p>
</body>
</html>
当鼠标hover
当鼠标不在
上一篇 下一篇

猜你喜欢

热点阅读