【发布时间】:2020-02-18 19:01:11
【问题描述】:
我正在制作一个网格格式的文档,当我将鼠标悬停在想要叠加的图像上时,它会随机出现在其下方。我将如何在文档中提高这种效果。 (目前唯一有效果的第一张图片)。由于某种原因,HTML 不会显示在此处的代码块中,所以我附上了我的 codepen,谢谢大家!
.flex {
display: grid;
grid-gap: 2rem;
grid-template-columns: repeat(3, 1fr);
margin: 0% 5% 5% 5%;
}
.resize {
max-width: 100%;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: cyan;
overflow: hidden;
width: 28%;
height: 0;
transition: .5s ease;
opacity: 0.3;
margin: 0% 0% 0% 5%;
}
.contained1:hover .overlay {
height: 35%;
width: 28%;
margin: 0% 0% 0% 5%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 90%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
font-family: 'karla';
}
代码笔:https://codepen.io/daniel-albano/pen/vYOKRzp?editors=1100
【问题讨论】:
-
codepen 是空的
-
抱歉,刚刚保存,现在应该可以显示了
-
您只需将 z-index: 1 添加到叠加层。 Z-index 优先考虑图层。数字越大 - 层越高。 ` .overlay { z-index: 1; } `
标签: javascript html css overlay css-grid