100% width Css issue only on mobile safari

后端 未结 5 2102
既然无缘
既然无缘 2021-01-30 11:41

Here is the site in question: www.prestigedesigns.com

The problem is that my header and footer won\'t stretch to their assigned 100% but only on iPhone/iPad.

I\

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-30 11:45

    It's kind of a viewport issue with mobile Safari, but you can get the same effect by shrinking the width of your desktop browser window and scrolling right, you'll see your background starts dropping out.

    This is because when you're setting width:100% to your #top and #header divs, you're telling them to resize to the width of the containing element, which in this case is the browser window, (or viewport). You're not telling them to resize to the content within.

    Mobile Safari's default viewport width is 980px, so it uses 980px as the width of the containing element for your divs. This is why your layout, which is around 1050px, is getting its background chopped off.

    You can fix this for mobile Safari by directly setting its viewport (read Apple's Docs), or by adding min-width:width of your design in pixels; to your body. Mobile Safari will use the min-width's value for setting its viewport, and it'll also keep it from happening in desktop browsers as well.

提交回复
热议问题