WordPress.org

Ready to get started?Download WordPress

Forums

Need help fixing a mobile theme (3 posts)

  1. secretsau
    Member
    Posted 1 year ago #

    I have created a mobile theme on WordPress and added the header code:

    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />

    I tested it on my smartphone and worked good. However when I rotated the screen, it didn't stretch out the entire website.

    How do I make the theme stretch out on rotating the screen on your smartphone.

    Thanks

  2. I've gotten it to work before with something similar to your <meta> tag and some js.

    <script>
        var metas = document.getElementsByTagName('meta');
        var i;
        if (navigator.userAgent.match(/iPhone/i)) {
          for (i=0; i<metas.length; i++) {
            if (metas[i].name == "viewport") {
              metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
            }
          }
          document.addEventListener("gesturestart", gestureStart, false);
        }
        function gestureStart() {
          for (i=0; i<metas.length; i++) {
            if (metas[i].name == "viewport") {
              metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
            }
          }
        }
      </script>

    There are plenty of other methods scattered around stackoverflow as well.

  3. secretsau
    Member
    Posted 1 year ago #

    Thanks buddy..

    But that just makes the website zoom in and out.

    Is there a way to force the website on the mobile browser not to rotate when you turn the smartphone ?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.