復制代碼代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>mask-layer</title>
</head>
<style type="text/css">
*{margin:0;padding: 0;}
ul{margin:100px auto 0; width:200px;}
img{border: 0 none;}
li{background-color:#555;list-style: none; width: 146px; height: 220px;}
a:hover{opacity: 0.6;}
</style>
<body>
<ul>
<li><a href=""><img src="http://h.hiphotos.baidu.com/baike/s%3D220/sign=700b0c26462309f7e36faa10420f0c39/64380cd7912397dd9e0581b65982b2b7d0a28707.jpg" alt="" /></a></li>
</ul>
</body>
</html>
原理:給li加上背景,li的大小就是圖片的大小,在a:hover時候改變a的透明度