一个简单的处理img加半透明背景技巧

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 5     <title>mask-layer</title>
 6 </head>
 7 <style type="text/css">
 8 *{margin:0;padding: 0;}
 9 ul{margin:100px auto 0; width:200px;}
10 img{border: 0 none;}
11 li{background-color:#555;list-style: none; width: 146px; height: 220px;}
12 a:hover{opacity: 0.6;}
13 </style>
14 <body>
15 <ul>
16     <li><a href=""><img src="http://h.hiphotos.baidu.com/baike/s%3D220/sign=700b0c26462309f7e36faa10420f0c39/64380cd7912397dd9e0581b65982b2b7d0a28707.jpg" alt="" /></a></li>
17 </ul>
18 </body>
19 </html>

原理:给li加上背景,li的大小就是图片的大小,在a:hover时候改变a的透明度;

演示地址:http://sandbox.runjs.cn/show/ghs7ugjl

posted on 2013-01-13 15:50  _Novice  阅读(519)  评论(0编辑  收藏  举报