时间:2021-05-08
先来一个简单的实现方法:
复制代码代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.mask-wrapper {
position: relative;
overflow: hidden;
}
.mask-inner {
position: absolute;
left: 0;
top: 100%;
width: 100%;
height: 100%;
-moz-transition: top ease 200ms;
-o-transition: top ease 200ms;
-webkit-transition: top ease 200ms;
transition: top ease 200ms;
}
.mask-wrapper:hover .mask-inner {
top: 0;
}
#my-mask {
width: 300px;
height: 200px;
background: red;
}
#my-mask .mask-inner {
background: rgba(0,0,0,.5);
}
</style>
</head>
<body>
<div id="my-mask" class="mask-wrapper">
<p>Lorem ipsum</p>
<div class="mask-inner">
<p>foo bar</p>
</div>
</div>
</body>
</html>
效果图:
来个更高级点的:
复制代码代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
font: 12px/1.5 arail;
}
ul {
list-style: none;
}
.icon-lists {
overflow: hidden;
background: #f7f7f7;
padding: 40px;
}
.icon-lists .box {
float: left;
margin-right: 10px;
}
.box {
position: relative;
width: 46px;
height: 46px;
overflow: hidden;
z-index: 1;
}
.box i, .box .info {
display: block;
width: 46px;
height: 46px;
border-radius: 46px;
}
.box .shadow {
position: absolute;
top: 0;
z-index: 10;
border-radius: 0;
background: url(<a href="http://xiaomingming.qiniudn.com/shadow.png">http://xiaomingming.qiniudn.com/shadow.png</a>) no-repeat;
}
.box .icon {
position: absolute;
top: 0;
line-height: 46px;
text-align: center;
background: #eee;
color: #333;
font-size: 14px;
}
.box .info {
position: absolute;
top: 46px;
z-index: 2;
background: orange;
color: #fff;
text-align: center;
line-height: 46px;
-webkit-transition:top .2s ease-in;
-moz-transition:top .2s ease-in;
transition:top .2s ease-in;
}
.box:hover>.info {
top:0;
}</p><p> </style>
</head>
<body>
<ul class="icon-lists">
<li class="box">
<i class="shadow"></i>
<i class="icon">A</i>
<div class="info">服装</div>
</li>
<li class="box">
<i class="shadow"></i>
<i class="icon">B</i>
<div class="info">鞋包</div>
</li>
<li class="box">
<i class="shadow"></i>
<i class="icon">C</i>
<div class="info">配饰</div>
</li>
<li class="box">
<i class="shadow"></i>
<i class="icon">D</i>
<div class="info">运动</div>
</li>
</ul>
</div>
</body>
</html>
效果图:
以上就是这篇文章的全部内容,希望对大家的学习和工作能带来一定的帮助。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了js鼠标悬浮出现遮罩层的方法。分享给大家供大家参考。具体实现方法如下:html页面代码:复制代码代码如下:科学动漫生活插画音乐自然js代码:复制代
实际开发中常常少不了使用弹窗,在学习css3的时候我发现可以通过纯css实现带遮罩层可关闭的弹窗。使用CSS3实现带遮罩层可关闭的弹窗需要用到:target伪类
想大家都做过遮罩层这种常见的功能,css或jquery实现,实现方式多样化,这里http://我介绍我在项目中实现的方式,全屏遮罩,部分区域可操作,非常实用。效
在开发中,为了避免二次提交,遮罩层的运用越来越普遍。 看了很多代码,下面跟大家分享一下我认为最简单的遮罩层实现方式: 1.样式如下设置: CSS代码:
鼠标hover以后。图片上面出现一个遮罩,透明度变化,显示设置好的文字的文字,完全使用css实现,下图是效果关键代码复制代码代码如下:.featured-ima