A 1 pixel gap only coming on iPad but fine on Safari and Chrome

13,262

Solution 1

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:

<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">

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:

Solution 2

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.

Solution 3

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.

Share:
13,262
Jitendra Vyas
Author by

Jitendra Vyas

Hi, I am Jitendra a front-end developer from India specializing in web standards, accessibility, and usability based development.

Updated on July 31, 2022

Comments

  • Jitendra Vyas
    Jitendra Vyas almost 2 years

    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.

    enter image description here

    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}