当您将鼠标悬停在图像容器上时,我想在文本上滚动。
我做得很好,但只是在绝对位置上,但我不能在位置相对上做对。
现在文本在图像之后,但我需要文本作为图像底部的小叠加层
<div class="ce_image team block">
<figure class="image_container">
<img src="assets/images/c/De****-D1-6a7e730c.jpg" width="300" height="300" alt="">
<figcaption class="caption" style="width:300px">The text i want to display on hover</figcaption>
</figure>
</div>
CSS:(PS:我问我的CSS真的很糟糕,从来没有这样做过SMTH)
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
display: none !important;
display: fixed;
color: #000000;
font-weight: bold;
position: static !important;
text-align: center;
top: 100px;
z-index: 999;
opacity: 0;
transition: opacity 0.2s linear !important;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
top: -31px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: relative;
display: block !important;
}
在这里摆弄 css:
https://jsfiddle.net/vm73gfhn/
我更新了一些 CSS,以便文本位于底部。你需要位置绝对而不是位置相对:
.image_container {
position: relative;
display: inline-block;
padding: 0.75em;
border: 1px solid #b2b9c4;
border-radius: 2px;
background: #ffffff;
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.02));
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
.team .image_container figcaption, .team .image_container .caption {
display: none !important;
}
.team .image_container:hover figcaption, .team .image_container:hover .caption {
width: 100% !important;
padding: 0.42857em 0 0;
font-size: 1.0em;
color: #000000;
font-weight: bold;
text-align: center;
bottom: 0px;
z-index: 999;
opacity: 1;
left: 0px;
background: rgba(255, 255, 255, 0.9);
position: absolute;
display: block !important;
}
吉斯菲德尔
附加
如果您希望它适用于移动设备和平板电脑,请使用媒体查询:http://www.w3schools.com/cssref/css3_pr_mediaquery.asp