【问题标题】:Different center in Chrome and Safari with same CSS codeChrome 和 Safari 中的不同中心具有相同的 CSS 代码
【发布时间】:2015-08-24 20:55:31
【问题描述】:

我正在尝试制作一个投资组合网站。该网站已完成,但在不同的浏览器中其结果不同。在 Chrome 中一切正常,但在 Safari 中,事情变得很奇怪。我的英雄文本框和英雄图像图标在 chrome 中居中,在 safari 中居中,无需更改代码。我在下面发布了一些代码和图片。

.hero-text-box {
    position: absolute;
    width: 1140px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.hero-icon-box {
    position: absolute;
    width: 1140px;
    top: 92%;
    left: 50%;
    transform: translate(-50%, -50%);
}

第一张图片是 chrome,第二张是 safari。

【问题讨论】:

  • 我认为您可以使用媒体查询来修复它。
  • @Deepak saini 解决方案如下:)

标签: javascript html css google-chrome safari


【解决方案1】:

transform 使用-webkit- 前缀

.hero-text-box {
    position: absolute;
    width: 1140px;
    left: 50%;
    top: 50%;
    -webkittransform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}
.hero-icon-box {
    position: absolute;
    width: 1140px;
    top: 92%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-04
    • 2017-01-22
    • 1970-01-01
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多