首页 > 代码库 > 半透明遮罩层
半透明遮罩层
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
</style>
</head>
<style>
.ul-case-i{
list-style: none;
margin-top: 200px;
}
.ul-case-i li{
float:left;
padding: 0 15px;
overflow: hidden;
}
.ul-case-i li a{
display: block;
position: relative;
transition: 0.3s;
-webkit-transition:0.3s;
color:#333;
text-decoration: none;
}
.ul-case-i li .pic img{
width:100%;
display: block;
}
.hover{
position:absolute;
left:0;
top:-100%;
width:100%;
height:100%;
text-align: center;
background: #363636;
opacity: 0.5;
color:#fff;
transition: 0.3s;
-webkit-transition:0.3s;
}
.hover b{
width:0;
height:100%;
display: inline-block;
vertical-align: middle;
}
.txt{
display: inline-block;
vertical-align: middle;
}
h3{
font-weight: normal;
}
</style>
<body>
<ul class="ul-case-i">
<li>
<a>
<div class="pic"><img src="http://www.mamicode.com/images/1-1604211551200-L.jpg" alt="柏林家政"></div>
<div class="hover">
<b></b>
<div class="txt">
<img src="http://www.mamicode.com/images/logo_small.png" >
<h3>VVVVVV</h3>
</div>
</div>
</a>
</li>
</ul>
</body>
<script src="http://www.mamicode.com/js/jquery-1.4.2.min.js"></script>
<script>
$(function(){
$(‘.ul-case-i‘).mouseover(function(){
$(‘.hover‘).css(‘top‘,‘0%‘);
});
$(‘.ul-case-i‘).mouseout(function(){
$(‘.hover‘).css(‘top‘,‘-100%‘);
})
})
</script>
</html>
半透明遮罩层