iPad background for div blocks not spanning entire width of screen

前端 未结 8 1358
既然无缘
既然无缘 2020-12-04 23:01

I\'ve had a continued problem with div blocks stretching along the entire width of my iPad\'s screen. It seems to stop about 20 pixels from the right side of the screen.

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 23:13

    You're seeing the problem on the iPad because its default viewport is 980 pixels (see Apple's docs ). So the effect you're seeing is the same as if you shrink your desktop browser to less than 1000 pixels, and scroll to the right (it does the same thing).

    You'll notice the size of the gap changes depending on the width of the browser window. This is because when you're setting width:100% to your wrapper divs, you're telling them to resize to the width of the containing element, which in this case is the browser window, or the iPad's viewport. You're not telling them to resize to the content within.

    @sandeep's solution is the correct one, and how you've implemented it works fine for me in Safari but not in any browser other I try it in. Are you user agent sniffing to serve the code to only Safari? If so, there's no need, you can just apply the min-width:1024px, or even just min-width:1000px to your body tag, or .footerbg however you normally apply CSS.

提交回复
热议问题