复制代码
代码如下:<!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="/uploads/allimg/210509/1144044D7-0.jpg" alt="" /></a></li>
</ul>
</body>
</html>
原理:给li加上背景,li的大小就是图片的大小,在a:hover时候改变a的透明度