【发布时间】:2017-10-30 08:04:01
【问题描述】:
我正在使用以下代码来显示一个仅使用 CSS 的简单灯箱。 (我不想使用 Javascript)。
.lightbox {
display: none;
position: fixed;
z-index: 999;
width: 100%;
height: 100%;
text-align: center;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
}
.lightbox img {
position: fixed !important;
top: 50% !important;
transform: translateY(-50%) translateX(-50%);
width: 70%;
}
.lightbox figcaption {
display: inline;
position: fixed!important;
top: 70% !important;
right: 5%;
transform: translateX(0%);
color: white;
}
@media (max-width: 500px) {
.lightbox img {
width: 90%;
}
}
@media (min-width: 800px) {
.lightbox img {
width: 50%;
}
}
<a href="#img1"><img class="img-thumbnail" src="img/sensei/kieflesson.jpg"></a>
<a href="#_" class="lightbox" id="img1">
<figure><img src="img/sensei/kieflesson.jpg">
<figcaption>Test22</figcaption>
</figure>
</a>
如您所见,我一直在尝试使用 figcaption 在图像下方立即添加标题。我设法让它显示,但它没有响应。我希望它随着图像大小的变化而移动。
任何帮助将不胜感激。
【问题讨论】: