【发布时间】:2017-05-25 12:32:24
【问题描述】:
我需要悬停叠加层与图像的宽度相同。所有具有该叠加效果的图像大小不同,但使用相同的类。 我找到了类似问题的答案,但它们都包括我需要相反的 css“绝对”和“相对”属性。我试过了,但它使悬停效果停止工作。 对此问题的任何帮助将不胜感激。 谢谢,海伦
P.S.:你知道,我对编码还很陌生,而且我不是说英语的人……
<!-- HTML mark-up -->
<div class="container">
<a href="#img1">
<img src="resources/img/hgdgdg_TH1.jpg" class="thumbnail" id="linathi_1">
<div class="overlay">
<div class="caption"><i class="ion-ios-pricetag"> €150</i></div>
</div>
</a>
</div>
/* CSS OVERLAY ON HOVER */
.container {
position: relative;
width: 100% /*50%*/;
}
.thumbnail /* image */ {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: rgba(180, 81, 64, 0.85);
overflow: hidden;
width: 100%;
height: 0;
-webkit-transition: .5s ease;
transition: .5s ease;
}
.container:hover .overlay {
bottom: 0;
height: 100%;
}
.caption {
white-space: nowrap;
font-family: 'Assistant', 'Arial', sans-serif;
font-style: normal;
font-size: 130%;
color: #fff;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
width: 100%;
text-align: center;
}
【问题讨论】: