【问题标题】:Background color width of <figcaption> works fine in Chrome, but does not display properly in Safari<figcaption> 的背景颜色宽度在 Chrome 中工作正常,但在 Safari 中无法正确显示
【发布时间】:2016-08-17 23:36:50
【问题描述】:

经过长时间的休息后,我开始尝试使用 webdev,但无法弄清楚为什么 Figcaption 无法在 Safari 中正确显示。

我创建了网站 www.suezre.com,当在 Chrome 或 Firefox 中查看时,图片上的 figcaption 看起来不错,但在 Safari 上它需要更多空间。

有什么建议可以解决这个问题吗?

谢谢 回复

<figure>
  <img src="../img/budapest_our_home_city.png"/>
  <figcaption>Budapest, our home city</figcaption>
</figure>

figure {
position: relative;
}

figcaption {
  position: absolute;
  bottom: 0;
  padding:  15px;
  color: white;
  background-color: rgba( 29, 20, 17, .6);
  text-align: right;
  text-transform: uppercase;
  font-size: 1rem;
  width: 100%;
}

.banner img {
    max-width: 100%;
    text-align: center;
    display: block;
    margin: auto;
}

【问题讨论】:

    标签: html css safari


    【解决方案1】:

    (在此处将the response 添加到类似问题。)

    我将display: tablemargin: auto 添加到figure,并将display: table-caption 添加到figcaption。之后似乎两者都可以正常工作。

    【讨论】:

    • 嗨托比,非常感谢你,我确实尝试在块和内联块中显示它,但不是表格。它确实解决了问题!非常感谢,以后会注意的!
    • 太棒了。学到了一些东西,我自己。 ;D
    猜你喜欢
    • 1970-01-01
    • 2012-08-21
    • 2019-01-05
    • 2015-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    相关资源
    最近更新 更多