【问题标题】:What is the best way to center text in the Safari Browser在 Safari 浏览器中居中文本的最佳方法是什么
【发布时间】:2017-03-20 18:44:20
【问题描述】:

我正在使用 CSS 在图像上放置叠加颜色。在 IE、Opera、Chrome 和 Firefox 中一切正常。我在 Safari 中遇到的唯一困难是覆盖显示时出现的文本拒绝在 Safari 浏览器(5.1.7 - Windows)中正确居中。下面是 CSS 代码文本部分的代码。如果您需要更多工作,请告诉我。

.text {
    width: 100%;
    white-space: nowrap;
    margin-left:auto;
    text-align: center;
    text-align: -moz-center;
    text-align: -webkit-center;
    margin-right:auto;
    color: white;
    font-family: "Times New Roman", Times, serif;
    font-size: 2.0em;
    font-weight: bold;
    position: absolute;
    overflow: visible;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    z-index: 9;
}

【问题讨论】:

  • HTML 的基本视图会很有用。您的 .text 与您的图片有什么关系?是父母/孩子还是兄弟姐妹?
  • 如果宽度为 100%,它将如何居中?

标签: css


【解决方案1】:

您提供的代码丢失 -webkit-transform: translate(-50%, -50%);添加这个仍然会产生问题吗?

【讨论】:

    猜你喜欢
    • 2010-10-09
    • 2018-02-14
    • 2011-06-16
    • 2011-09-23
    • 2015-06-21
    • 2010-09-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    相关资源
    最近更新 更多