css - 将 <figcaption> 缩小到兄弟 <img> 并保持响应

标签 css figure

这是说明的问题: here

我想使图形标签的边框适合 img。

这是html结构:

<div class="container">
    <figure>
        <img src="" alt="">
        <figcaption></figcaption>
    </figure>
</div>

这是CSS:

figure {
    border: 1px solid $color-light-gray;
    padding: 5px;

    img {
        max-width: 100%;
        height: 100%
    }

    figcaption {
        text-align: center;
    }
}

最佳答案

在图中使用display:table,在figcaption中使用display:table-caption

关于css - 将 <figcaption> 缩小到兄弟 <img> 并保持响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52822338/

相关文章:

layout - 在 multicol 环境中跨越两列的非 float 图形

html - 如何使矩形的边框不同?

css - Firefox 中的填充不同

javascript - 同位素垂直标签需要在加载时显示第一项

css - 使主页为屏幕高度的 100%

javascript - Bootstrap 向导/步骤表单

matlab - 当图形退出Matlab时有效地中断循环

javascript - 当从移动设备长按我的网站图像时出现设计问题

Latex:当图形覆盖整个页面时抑制页码

python - 如何将 matplotlib 图旋转 90 度?