CSS 滤镜属性 设置图片不透明度
通过一个简单的实例介绍如何在网页中设置图片的不透明度,让图片在正常情况下的不透明度为50%,鼠标移入之后则100%显示。
【例题】设置图片的不透明度
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
background: #ccc;
}
h1{text-align: center;}
.container{
width: 750px;
margin:20px auto;
height: 500px;
border:1px solid #fff;
background: #fff;
padding:25px;
}
img{
display:block;
float:left;
margin:25px;
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity: 0.5;
}
img:hover{
filter:alpha(opacity=100);
-moz-opacity:1;
opacity: 1;
}
</style>
</head>
<body>
<h1>鼠标移入图片正常显示</h1>
<div>
<img src="tomjerry.jpg" alt="">
<img src="tomjerry.jpg" alt="">
<img src="tomjerry.jpg" alt="">
<img src="tomjerry.jpg" alt="">
<img src="tomjerry.jpg" alt="">
<img src="tomjerry.jpg" alt="">
</div>
</body>
</html>
点击加载更多评论>>