gpt4 book ai didi

html - 悬停时图片显示文本为 "rollover"

转载 作者:行者123 更新时间:2023-11-28 17:07:48 24 4
gpt4 key购买 nike

当您将鼠标悬停在图像容器上时,我想制作一个“滚动文本”。

我做得很好,但只有绝对位置,但我不能用相对位置。

现在文本出现在图像之后,但我需要文本作为图像底部的小覆盖层

<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 真的很糟糕,从来没有像这样制作过)

   .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;
}

JSFIDDLE

额外的

如果您希望它适用于手机和平板电脑,请使用媒体查询: http://www.w3schools.com/cssref/css3_pr_mediaquery.asp

关于html - 悬停时图片显示文本为 "rollover",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29947073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com