【问题标题】:text-align: center; not working in Safari文本对齐:居中;不能在 Safari 中工作
【发布时间】:2018-04-05 17:04:41
【问题描述】:

我有这个 HTML

<section id="selection">
<a href="shop.html#shopBags"><img src="img/coverpictures/frontpage01.jpg"></a>
<a href="shop.html#shopAttachments"><img src="img/coverpictures/frontpage02.jpg"></a>
<a href="shop.html#shopAccessories"><img src="img/coverpictures/frontpage03.jpg"></a>
</section>

有了这个 CSS

#selection{
  text-align: -webkit-center;
  text-align: -moz-center;
  word-spacing: 4vw;
  margin: 0;
}

#selection img{
  width: 25%;
  text-align: center;
}

我希望三个链接/图像在 div 中居中。它在 Chrome 和 Firefox 中运行良好,但在 Safari 中图片浮动正确。我该如何解决这个问题?

【问题讨论】:

  • euh,以及关于容器内的 test-align:center 而不是 img ?也删除其他的..
  • 这是一个来自 safari 的 bug,bugs.webkit.org/show_bug.cgi?id=40216 从 2010 年到现在。
  • @Troyer 什么??你在开玩笑吗?

标签: html css safari text-align


【解决方案1】:

试试这个

#selection{
    display:flex;
    justify-content:center;
    }

【讨论】:

  • 图像给定边距:自动
  • 它适用于 margin:auto。我认为是字母间距弄乱了它。如何在不影响居中的情况下获得图像之间的间距?
  • 内边距:10px 10px 10px 10px;你可以给自己的填充
  • @S.Drescher 你是不是简单地尝试了text-align:center 没有任何前缀??
猜你喜欢
  • 2015-05-17
  • 1970-01-01
  • 2017-05-17
  • 2015-09-07
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 2016-02-15
相关资源
最近更新 更多