【发布时间】:2017-10-02 18:17:43
【问题描述】:
我试图让 <figcaption> 元素的内容宽度超过 <img> 同级元素的宽度时呈现滚动条,通常是当内容是长 URL 或非常长的单词时。
以下代码改编自this answer,适用于 IE 11 和 Edge 15,但不适用于 Firefox 55 和 Chrome 61:
* {
outline: 1px solid red;
}
figure {
display: table;
max-width: 100%;
}
figure img {
vertical-align: top;
}
figure figcaption {
display: table-caption;
caption-side: bottom;
overflow: auto;
}
<figure>
<img src="//via.placeholder.com/220x100" alt="">
<figcaption>Long word in figure caption Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatak</figcaption>
</figure>
【问题讨论】:
-
在 IE 11 和 Edge 15 中的样子:i.stack.imgur.com/DPIUa.png