我的下拉菜单使用以下 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/
下拉菜单位于导航栏上的“Expat Coaching”下。
最佳答案
在父 li
元素上尝试 position: relative
:
header nav ul #expatSub {
width: 166px;
position: relative;
}
并从那里设置嵌套 ul
元素的 top
和 left
:
header nav ul #sublist {
/* ... */
position: absolute;
left: 0;
top: 40px;
z-index: 1;
/* ... */
}
关于css - 具有绝对定位元素的 Chrome 和 Safari 之间一个像素的水平偏移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24099968/