标签:background absolute position jquery relative
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery打造鼠标悬停图片时的半透明遮罩效果</title>
<style>
*{margin:0;padding:0;}
li{list-style:none;}
.box{width:800px;height:400px;margin:50px auto;overflow:hidden;}
.box ul li{width:200px;height:200px;float:left;position:relative;overflow:hidden;}
.box ul li .dask{width:170px;height:180px;padding:20px 0 0 30px;background:#000;opacity:0.8;position:absolute;top:-200px;left:0;}
.box ul li .dask p{color:#fff;}
.box ul li .dask a{color:green;text-decoration:none}
</style>
<script type="text/javascript" src="/ajaxjs/jquery-1.9.1.min.js"></script>
<script>
$(function () {
$(".box ul li").hover(
function () {
$(this).find(".dask").stop().delay(50).animate({"top":0,opacity:0.8},300)
},
function () {
$(this).find(".dask").stop().animate({"top":-200,opacity:0},300)
}
)
})
</script>
</head>
<body>
<div class="box">
<ul>
<li>
<a href="www.nftx8.com"><img src="/jscss/demoimg/wall_s1.jpg" width="200" height="200" /></a>
<div class="dask">
<p>荃银高科</p>
<p>天穿</p>
<a href="/">您想不到的美景</a>
</div>
</li>
<li>
<a href="www.nftx8.com"><img src="/jscss/demoimg/wall_s2.jpg" width="200" height="200" /></a>
<div class="dask">
<p>落日</p>
<p>天错时</p>
<a href="/">自然美</a>
</div>
</li>
</ul>
</div>
</body>
</html>
将img里面src换成你本地的图片名字就可以了
标签:background absolute position jquery relative
原文地址:http://wwwnftx8com.blog.51cto.com/9686769/1627339