我想在悬停在多个彩色DIV上的图像上创建悬停效果。我想我可以用CSS做到这一点,但是我很难得到我想要的结果。DIV在悬停时显示多个颜色叠加
什么我瞄准了它看起来像在最后:
HTML:
<div class="row thumbrow">
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-4 thumbgrid">
<li>
<div class="thumb">
{{ cms:page_file:thumb_one.image:image}}
<span class="center">{{ cms:page:thumb_one.text:string }}</span>
<div class="yellow">
</div>
</div>
</li>
</ul>
</div>
CSS:
.thumb {
display:inline-block;
position: relative;
height: 170px;
overflow: hidden;
}
.thumb:after {
background: rgba(255,255,255,.8);
content:'';
display: block;
height: 170px;
left: 0;
opacity: 0;
padding: 20px;
position: absolute;
top: 0;
width: 100%;
z-index: 1;
}
.thumb:hover:after {
opacity: 1;
padding: 20px;
transition: opacity .4s;
}
.thumb:hover .yellow {
content:'';
display: block;
height: 170px;
left: 0;
opacity: 1;
position: relative;
top: 0;
width: 100%;
z-index: 5;
background: #f9d33a;
}
span.center {
color: white;
position: relative;
top: -100px;
z-index: 3;
}
喜@Eric - 为'.yellow'类 - 的CSS将是'position:absolute:left:5px;顶部:5p;右侧:5px;底部:5px' - (或类似的味道值)。这是你缺少的'绝对位置'。 '.center' css类相同。要堆叠它们,添加css'zindex:1','z-index:2'。 –
啊,非常感谢。如果你把这个答案,我会接受它是正确的:) –
伟大的东西。补充说。祝一切顺利。 –