html - 在 Html 中,如何在图像本身上显示 Bootstrap Badge

标签 html css bootstrap-4

我有一个图像网格,对于每个图像,我有两个 figcaption 元素呈现为每个图像下方的徽章(加上第三个正确呈现为超链接),我真正想做的是将徽章放在底部图像本身,但不知道如何做到这一点。

<div style="display:grid;grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));grid-gap: 5px;">
    <div>
        <figure class="figure">
            <a href="FixSongsReport00277_changes00041.html">
                <img src="../images/Antonin Dvorak; Itzhak Perlman, Daniel Barenboim, Samuel Sanders.jpg" class="figure-img" width="200" height="200">
            </a>
            <figcaption class="badge badge-secondary">
                12 files 
            </figcaption>
            <figcaption class="badge badge-secondary">
                0 files modified
            </figcaption>
            <figcaption class="figure-caption">
                <a href="FixSongsReport00277_changes00041.html">
                    Antonin Dvorak; Itzhak Perlman, Daniel Barenboim, Samuel Sanders
                </a>
            </figcaption>
        </figure>
    </div>
    <div>
        <figure class="figure">
            <a href="FixSongsReport00277_changes00029.html">
                <img src="../style/images/folder.jpg" class="figure-img" width="200" height="200">
            </a>
            <figcaption class="badge badge-secondary">
                27 files 
            </figcaption>
            <figcaption class="badge badge-secondary">
                0 files modified
            </figcaption>
            <figcaption class="figure-caption">
                <a href="FixSongsReport00277_changes00029.html">
                    Choir of Trinity College
                </a>
            </figcaption>
        </figure>
    </div>

例如

enter image description here

基于 Olegs 的回答我现在有了

enter image description here

最佳答案

您可以使用 CSS 使它们位于图像之上

.badge{
   position: relative;
   top: -3em;        
}

.figure-caption {
  position: relative;
  top: -2em
}

这是附件 JSFiddle

关于html - 在 Html 中,如何在图像本身上显示 Bootstrap Badge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57042978/

相关文章:

html - 显示 :none doesn't hide the div content

javascript - 如何淡出页面然后定向到新页面

javascript - 投票/评分系统 : How to fail gracefully when javascript isn't supported/enabled?

Css IE 样式问题 - 如何在 IE 中更正这个简单的导航菜单?

css - Bootstrap 容器-流体与 float 元素发生碰撞

html - 容器类右侧的额外空白

html - EM 中的宽度不符合我的预期

html - 如何制作这样的 table

javascript - 如何使用 Bootstrap 正确创建 block 引用

python-3.x - 如何向表添加分页(Django)