大佬教程收集整理的这篇文章主要介绍了如何在网格库中每张照片的底部中间放置标题?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在图像底部放置一个标题,就在我的网格画廊中每张照片的中间,带有浅灰色背景,以便无论我使用什么图像都@R_262_11219@见?到目前为止,我只设法将文本放在下面,但没有放在图像上。感谢您的时间,这是我的代码:
body {
margin: 0
}
.container {
display: grID;
grID-template-@R_673_8620@ns: repeat(auto-fit,minmax(250px,1fr));
gap: 20px;
BACkground: rgb(255,255,255);
padding: 15px;
}
.container img {
wIDth: 80%;
display: block;
BACkground-color: cornflowerblue;
border-radius: 12%;
}
.container img:hover {
transform: scale(1.04);
}
h2,p {
Font-family: Arial,Helvetica,sans-serif;
Font-weight: lighter;
}
.overlay {
position: absolute;
bottom: 10px;
left: 19px;
Font-size: 13px;
}
<div class="container">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
<img src="placeholder-image.png" alt="photo">
</div>
在 figure
元素中插入您的图片。为文本添加 figcaption
。
.container {
display: grid;
grid-template-@R_673_8620@ns: repeat(auto-fit,minmax(250px,1fr));
}
figure {
position: relative;
display: flex;
justify-content: center;
}
figcaption {
position: absolute;
bottom: 15px;
left: 50%;
transform: translateX(-50%);
BACkground-color: rgba(0,.2);
padding: 5px;
}
img {
width: 80%;
display: block;
}
<div class="container">
<figure>
<img src="http://i.imgur.com/60PVLis.png" alt="">
<figcaption>@R_968_3801@ text</figcaption>
</figure>
<figure>
<img src="http://i.imgur.com/60PVLis.png" alt="">
<figcaption>@R_968_3801@ text</figcaption>
</figure>
<figure>
<img src="http://i.imgur.com/60PVLis.png" alt="">
<figcaption>@R_968_3801@ text</figcaption>
</figure>
<figure>
<img src="http://i.imgur.com/60PVLis.png" alt="">
<figcaption>@R_968_3801@ text</figcaption>
</figure>
<figure>
<img src="http://i.imgur.com/60PVLis.png" alt="">
<figcaption>@R_968_3801@ text</figcaption>
</figure>
</div>
以上是大佬教程为你收集整理的如何在网格库中每张照片的底部中间放置标题?全部内容,希望文章能够帮你解决如何在网格库中每张照片的底部中间放置标题?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。