Search code examples
ioscssiphoneviewport

How to center align the maximum-scale viewport zoom for iphone


When I set a maximum scale and when I rotates orientations back and forth, the web page isn't centered on the phone.

So using this code

  <meta name="viewport" content="width=device-width; initial-scale=0; maximum-scale=2;">

How can I mimic the CSS effect of margin: 0 auto;.


Solution

  • You will need to have a wrapper inside of another wrapper to get this to work. The outside one will have the following CSS:

    #wrapper {
    min-width: 320px;
    max-width: 480px;
    }
    

    And the inside one will have the following:

    #inside-wrapper {
    min-width: 300px;
    max-width: 460px;
    margin: 0 auto;
    }
    

    You can still use margin: 0 auto;