CSS实现鼠标悬浮出现遮罩层示例源码_ Div+Css教程-查字典教程网
CSS实现鼠标悬浮出现遮罩层示例源码
CSS实现鼠标悬浮出现遮罩层示例源码
发布时间:2017-01-07 来源:查字典编辑
摘要:先来一个简单的实现方法:Document.mask-wrapper{position:relative;overflow:hidden;}....

先来一个简单的实现方法:

<!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">

<p>Lorem ipsum</p>

<div>

<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>

<li>

<i></i>

<i>A</i>

<div>服装</div>

</li>

<li>

<i></i>

<i>B</i>

<div>鞋包</div>

</li>

<li>

<i></i>

<i>C</i>

<div>配饰</div>

</li>

<li>

<i></i>

<i>D</i>

<div>运动</div>

</li>

</ul>

</div>

</body>

</html>

效果图:

以上就是这篇文章的全部内容,希望对大家的学习和工作能带来一定的帮助。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新 Div+Css教程学习
    热门 Div+Css教程学习
    网页设计子分类