我确信这是一个简单的修复,但无法理解我做错了什么。我试图显示“标题文本”并减少图像悬停时图像的不透明度。我降低了图像不透明度,但除非直接悬停文本,否则似乎无法显示文本。任何帮助,将不胜感激!谢谢
#work {
.items {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 1rem;
.item {
position: relative;
background: $dark-color;
// overflow: hidden;
&:after {
content: '';
position: absolute;
display: block;
background: inherit;
opacity: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
// bring in main color overlay
&:hover:after {
opacity: 0.3;
}
&-text {
position: absolute;
top: 50%;
left: 0;
bottom: 0;
right: 0;
opacity: 0;
text-align: center;
z-index: 1;
color: #fff;
}
// bring in text on hover
&-image:hover &-text {
opacity: 1;
}
&-image:before {
content: '';
display: block;
padding-top: 75%;
overflow: hidden;
}
&-image img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: auto;
line-height: 0;
}
}
}
至尊宝的传说
qq_笑_17
相关分类