1 像素间隙仅在 iPad 上出现,但在 Safari 和 Chrome 上正常
云后的这条线,仅在 iPad 或 iPhone 中可见。知道如何解决吗?
在所有其他桌面浏览器中都很好。
CSS
#banner-inner { height: 270px; margin: 0 auto; position: relative; width: 954px;}
.cloud-bottom { position: absolute; background: url(images/clouds_dark.png) repeat-x 0 bottom ; z-index: 1; width:100%;height:111px;bottom:0}
.cloud-top { position: absolute; background: url(images/clouds_light.png) repeat-x 0 bottom ; z-index: 4;width:100%;height:111px;bottom:0}
Here at this line after clouds which will be only visible in iPad or iPhone. Any idea how to solve it?
It's fine in all other desktop browsers.
CSS
#banner-inner { height: 270px; margin: 0 auto; position: relative; width: 954px;}
.cloud-bottom { position: absolute; background: url(images/clouds_dark.png) repeat-x 0 bottom ; z-index: 1; width:100%;height:111px;bottom:0}
.cloud-top { position: absolute; background: url(images/clouds_light.png) repeat-x 0 bottom ; z-index: 4;width:100%;height:111px;bottom:0}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
当页面比例因子小于 1.0 时,这似乎是 iPad 上 WebKit 渲染引擎的一个错误。如果将页面比例因子保持在 1.0 以上,则像素间隙不会显示。这可以通过元标记来完成:
我还发现了一个简单的页面,演示了类似的问题(仅在 iPad 上出现渲染故障):
过去,WebKit 引擎中报告了许多关于舍入问题的错误:
This seems to be a bug of the WebKit rendering engine on the iPad, when the page scale factor is less than 1.0. If you keep the page scale factor above 1.0, then the pixel gap does not show up. This can be done with a meta tag:
I also found a simple page that demonstrate a similar issue (a rendering glitch on iPad only):
In the past, there have been a number of bugs reported for rounding issues in the WebKit engine:
如果不需要禁用缩放,并且边距技巧不起作用(它可能适用于背景颜色,但我无法使其适用于背景图像),这里是另一个解决方案:
将所有背景图像放大 1 或 2 像素(剪切它们,使它们包含上面/下面图形的 1 px 副本),并使用 css 背景大小和背景位置来确保不会显示额外的(不需要的)像素 - 只有在浏览器打开时才会使用它需要额外的像素来覆盖渲染间隙。
已测试修复 Android 2.3 默认浏览器上的渲染错误(将于周一在 iPhone 和 iPad 上进行测试),以及 PC 上 Chrome 中的缩放错误。
If disabling zoom is not wanted, and if the margin trick does not work (it probably works with background colors, but I could not get it to work with background images), here is another solution:
Make all background images 1 or 2 px bigger (cut them so they contain a 1 px duplicate of the graphics above/below), and use css background-size and background-position to ensure that the extra (unwanted) pixel is not shown - it will then only be used if the browser needs that extra pixel to cover the rendering gap.
Tested to fix the rendering bug on Android's 2.3's default browser (will test on iPhone & iPad on monday), plus zooming errors in Chrome on PC.
我还通过使用 Overflow-x:hidden; 解决了 iOS 子像素间隙问题(在全屏网站上)。停止横向滚动&视点缩放以停止俯仰缩放。我还将holder div设置为width: 101%;并将里面的所有元素/图像 div 设置为 float: left;。这意味着子像素间隙全部位于左侧站点,但被设置为 101% 宽度的支架 div 推到了视图之外。
I also solved the iOS sub pixel gap issue (on a full screen site) by using overflow-x: hidden; to stop side ways scrolling & viewpoint scale to stop pitch zooming. I also had holder divs set at width: 101%; and all the elements/image divs inside set to float: left;. This means the sub pixel gaps are all on the left hand site but pushed out of view by the holder div set at 101% width.
尝试一下,
可能还有一个小的分辨率问题,所以尝试一下,
其中之一也必须工作:)
更新:
我想我明白了,
Try this
may be there is a small resolution problem also so try this also
one of them has to work :)
UPDATE:
I think i got it,
尝试在
PX
中设置#banner
的高度,而不是在EM
中,并且云的高度都是 112px 和 113px,而不是 111px。Try to set the the height of the
#banner
inPX
not inEM
And the hieght of cloud is 112px en 113px not 111px for both.我发现当背景图像放大以匹配设备的分辨率时,往往会发生这种情况。我怀疑这是由于图像外边缘出现少量渗色所致,通常可以通过为更高像素密度的显示器(即本例中的视网膜)提供额外的背景版本来解决。
以下技巧对我来说非常有用:
上述解决方案在我的情况下非常有效。
I have found that this tends to occur when background images are up-scaled to match the resolution of the device. I suspect that this occurs due to a small amount of colour bleeding along the outer edges of your image which can usually be resolved by providing an additional version of your background for higher pixel density displays (i.e. retina in this case).
The following trick works great for me:
The above solution worked perfectly in my case.
当透明度关闭时,行为很有趣。即使作为 jpg,它也确实显示了这个工件。看起来像是 webkit 渲染引擎中的一个错误。
Funny beahviour, when transparancy is turned off. Even as jpg it does show this artifact. Looks like a bug in the webkit rendering engine.