<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" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="/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 class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="/jscss/demoimg/wall_s1.jpg" width="200" height="200" alt="" /></a>
<div class="dask">
<p>荃银高科</p>
<p>天穿</p>
<a href="/">您想不到的美景</a>
</div>
</li>
<li>
<a href="www.nftx8.com"><img class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="/jscss/demoimg/wall_s2.jpg" width="200" height="200" alt="" /></a>
<div class="dask">
<p>落日</p>
<p>天错时</p>
<a href="/">自然美</a>
</div>
</li>
</ul>
</div>
</body>
</html>
将img里面src换成你本地的图片名字就可以了
来源www.nftx8.com
共同学习,写下你的评论
评论加载中...
作者其他优质文章