Mobile Safari Viewport - Preventing Horizontal Scrolling?

后端 未结 6 691
轮回少年
轮回少年 2020-12-13 19:49

I\'m trying to configure a viewport for mobile Safari. Using the viewport meta tag, I am trying to ensure that there\'s no zooming, and that you can\'t scroll the view horiz

相关标签:
6条回答
  • 2020-12-13 20:00

    Is it possible that I've got some page element pushing the content out?

    Yes, that is indeed the case. The viewport setting only defines the visible viewport area but does not deal with turning off sideway panning.

    So, in order to avoid this from happening, set an overflow:hidden on the element that contains your content, or else, avoid elements from overflowing.

    NB: other mobile browsers also support the viewport meta tag since a while, so you'll want to test in those as well.

    0 讨论(0)
  • 2020-12-13 20:06

    Try this variants

    html, body{ overflow-x: hidden; }

    0 讨论(0)
  • 2020-12-13 20:09

    Don't know whether its just me or whether some of the code posted has been incorrectly typed, but:

    should this

    <meta name='viewport' content='content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0' />
    

    not read like this

    <meta name='viewport' content='width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0' />
    

    so content is only listed once with out " as it has no closing " at the end of the code.....

    0 讨论(0)
  • 2020-12-13 20:19

    Late to the party here, but I just had a similar problem where I had horizontal scrolling across an iPhone 5, the site was effectively showing as double the width, with the right hand half completely empty.

    In fact, I just needed to change the viewport meta tag from:

    <meta name='viewport' content='width=device-width, maximum-scale=1.0, minimum-scale=1.0' />
    

    to:

    <meta name='viewport' content='width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0' />
    

    Adding the 'initial-scale' locked it down so that it only scrolled vertically as expected.

    0 讨论(0)
  • 2020-12-13 20:24

    body div {overflow: hidden ;} @ media queries

    . This wil prevent any elemente pushing content out.

    0 讨论(0)
  • 2020-12-13 20:25

    body { overflow-x: hidden; } also works.

    0 讨论(0)
提交回复
热议问题