我一直在尝试使用纯css
在网站上制作叠加悬停效果 <div class="col-md-4 port-show">
<img class="img-responsive" alt="" src="">
<h2 class=""></h2>
<ul>
<li></li>
<li></li>
</ul>
</div>
但是当我将鼠标悬停在img 上时,我遇到了问题,因为叠加层不会触发。我知道我必须采用不同的方式,但现在不要这样做。 CSS:
:hover:after{
content: "";
z-index: 10;
display: block;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: red;
border-radius: 6px;
border-color: transparent;
}
答案 0 :(得分:1)
你可以看看这里。也许这个解决方案对你有帮助。
http://codepen.io/anon/pen/VKmxZw
.img-holder {
position: relative;
z-index: 1;
display: block;
width: 350px;
}
.img-holder img {
display: block;
width: 100%;
}
.img-holder:after {
content: " ";
width: 100%;
height: 100%;
background-color: red;
z-index: 2;
left: 0;
top: 0;
position: absolute;
opacity: 0;
}
.img-holder:hover:after {
opacity: 1;
}
&#13;
<div class="col-md-4 port-show">
<span class="img-holder">
<img src="http://placehold.it/350x150" />
</span>
<h2 class=""></h2>
<ul>
<li></li>
<li></li>
</ul>
</div>
&#13;
答案 1 :(得分:-1)
您可以按照此操作制作叠加效果
var details = _ctx.A
.Where (t=>t.Id ==something)
.Select(a => new {
Id = a.Id,
// ... other A properites ,
Bases = _ctx.Bases.OfType<Base1>().Select(m=> new {
Id = m.Id,
Name = m.Name,
SomeClass = m.SomeClass
});
}
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
h2 {
color: #c55;
padding: 50px 0;
text-align: center;
text-transform: uppercase;
}
.container {
background: url("http://static.pexels.com/wp-content/uploads/2015/03/fog-forest-haze-4827-524x350.jpeg");
background-size: cover;
background-position: center;
position: relative;
margin: auto;
width: 200px;
height: 200px;
cursor: pointer;
overflow: hidden;
}
.container:hover .overlay {
opacity: 1;
width: 100%;
height: 100%;
}
.container:hover .overlay span {
opacity: 1;
-webkit-transition: 1.3s ease;
transition: 1.3s ease;
}
.container .overlay {
background: rgba(0, 0, 0, 0.5);
position: absolute;
margin: auto;
width: 0px;
height: 0px;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
-webkit-transition: .3s ease;
transition: .3s ease;
}
.container .overlay span {
color: #fff;
text-align: center;
position: absolute;
margin: auto;
width: 180px;
height: 30px;
line-height: 30px;
left: 0;
top: 0;
right: 0;
bottom: 0;
opacity: 0;
}
答案 2 :(得分:-1)
一些简单的重叠代码:
<!DOCTYPE html>
<html >
<head>
<style type="text/css">
.pic{ width:190px;
height:190px; opacity: 1;
filter: alpha(opacity=100);
background: url(http://www.corelangs.com/css/box/img/duck.png) no-repeat; }
.pic:hover { opacity: 0.3; filter: alpha(opacity=30);}
</style>
</head>
<body>
<div class="pic">
</div>
</body>
</html>