【发布时间】:2018-07-24 18:39:31
【问题描述】:
您好,我正在尝试使用变换缩放效果和阴影背景在图像悬停时隐藏/显示绝对定位的文本,我在使用 z-index 和 div 容器时遇到了一些问题。我想要实现的是:
悬停前:
悬停时:
我知道我可以将文本包装到 div 中,然后在悬停时更改可见性或显示 css 属性,但这对我不起作用。这是我的代码:
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-lg-4 column" *ngFor="let clientProject of clientProjects; let i= index">
<button class="btn button-modal" data-toggle="modal" [attr.data-target]="'#' + i">
<span class="hidden-text">TEXT</span>
<img src="{{clientProject.clickImageButtonPath}}" class="img-fluid image">
</button>
</div>
</div>
</div>
css:
.image {
width: 100%;
height: 400px;
transition: all 0.3s ease-in-out;
z-index: 1;
opacity: 0.35;
}
.button-modal {
padding: 0 !important;
overflow: hidden;
background-color: black;
}
.button-modal:hover {
padding: 0 !important;
}
.hidden-text:hover + .image,
.image:hover {
transform: scale(1.2);
}
.column {
margin: 0 !important;
border: none;
padding: 0 !important;
}
.hidden-text {
display: block;
z-index: 2;
color: white;
font-size: 2rem;
border: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
position: absolute !important;
}
有人可以帮忙吗?
【问题讨论】:
-
嘿! :) 实际的 CSS 来自第二个屏幕。
标签: html css bootstrap-4