我的页面主体上有一个背景图像,应该垂直和水平居中并覆盖画布。
body {
background: #000;
overflow: hidden;
background: url(background_phone_2.jpg) no-repeat center center fixed;
background-size: cover;
}
在 Chrome/Firefox 和所有移动浏览器中,图像垂直和水平居中并覆盖画布。在桌面版 Safari 中,图像略低于垂直中心。我做错了什么或者这可能是浏览器错误吗?
这个直播网址是: http: //moonios.com
我已经尝试删除溢出:无以及删除页面的其他内容,但问题仍然存在。
如果您有任何建议或可以确认此错误,我将不胜感激。谢谢!查理
更新:做了更多的工作来解决这个问题。用网格构建这个新页面: http ://whyamicrazytoday.com/safari/
整个页面内容为:
<html>
<head>
<title>Safari Background Size Bug</title>
<style>
body {
background-image: url(background.png);
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
background-size: cover;
}
</style>
</head>
<body>
</body>
</html>
仍然只在 Safari 中重现。
然后我想起了 Safari 导航栏中的半透明效果(虽然我把它关掉了)。我相信 Safari 正在考虑用正文区域来覆盖顶部导航栏,这会导致我的垂直居中偏离,因为没有以这种方式考虑页面的内容。有没有办法从dom禁用这种效果?