蒙版

今天给大家介绍的是蒙版技巧,利用div设置半透明色来遮盖底部的图层或div,当鼠标移入的时候,半透明色的div就开始遮盖图层,已达到蒙版的效果。

css部分:

.box1{
width: 1024px;
height: 768px;
/*border: 1px solid #000;*/
position: relative;
/*超出部分隐藏*/
overflow: hidden;
margin: auto;
}

.mb_top{
width: 824px;
height: 200px;
/*半透明色*/
background-color: rgba(255,0,0,.5);
position: absolute;
top: -200px;
transition: all linear 1s;
text-align: center;
}
.box1:hover .mb_top{
top: 0;
}
.mb_bottom{
width: 824px;
height: 200px;
/*半透明色*/
background-color: rgba(255,0,0,.5);
position: absolute;
bottom: -200px;
left: 200px;
transition: all linear 1s;
text-align: center;
}
.box1:hover .mb_bottom{
bottom:0;
}
.mb_left {
width: 200px;
height: 568px;
/*半透明色*/
background-color: rgba(255,0,0,.5);
position: absolute;
left: -200px;
top: 200px;
transition: all linear 1s;
text-align: center;
}
.box1:hover .mb_left{
left: 0;
}
.mb_right {
width: 200px;
height: 568px;
/*半透明色*/
background-color: rgba(255,0,0,.5);
position: absolute;
right: -200px;
top: 0;
/*动画效果*/
transition: all linear 1s;
text-align: center;
}
.box1:hover .mb_right{
right: 0;
}


html部分:
<html>
<head lang="en">
<meta charset="UTF-8">
<title>蒙版 || 遮罩</title>
</head>
<body>
<div class="box1">
<img src="test_1.jpg" alt="pic"/>
<div class="mb_bottom">这是三只大企鹅</div>
<div class="mb_left">这是三只大企鹅</div>
<div class="mb_right">这是三只大企鹅</div>
<div class="mb_top">这是三只大企鹅</div>
</div>
</body>
</html>

效果如下:

原图层:

加了蒙版效果后:

 

 

转载于:https://www.cnblogs.com/hjl-x/p/7191411.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值