【问题标题】:Horizontal Offset of One Pixel between Chrome and Safari with Absolute Positioned ElementChrome 和 Safari 之间一个像素的水平偏移量与绝对定位元素
【发布时间】:2014-06-09 00:09:20
【问题描述】:

我的下拉菜单使用以下 CSS:

header nav ul #sublist {
    height: 98px;
    width: 166px;
    position: absolute;
    left: 155px;
    top: 381px;
    z-index: 1;
}

由于某种原因,该位置在 Safari 下向右更远一个像素。它恰好出现在我希望它与 Chrome 一起出现的位置。

我一直在调查,但找不到此偏移的来源。你可以在这里查看我的网站:

http://www.theexpatcoach.com/b/

下拉菜单位于导航栏上的“外籍教练”下方。

【问题讨论】:

  • 你试过翻译吗? top 和 left 0 并设置 transform: translate3d('155px', '381px','0px')
  • @keypaul 谢谢你的回答,虽然试过了,但似乎没有工作(出现在浏览器的左上角),好像没有指定位置一样

标签: css google-chrome safari css-position


【解决方案1】:

在父 li 元素上尝试 position: relative

header nav ul #expatSub {
  width: 166px;
  position: relative;
}

并从那里设置嵌套ul 元素的topleft

header nav ul #sublist {
/* ... */
position: absolute;
left: 0;
top: 40px;
z-index: 1;
/* ... */
}

【讨论】:

    猜你喜欢
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 2011-03-19
    • 1970-01-01
    • 1970-01-01
    • 2019-06-22
    相关资源
    最近更新 更多