Meta viewport ONLY for phones?

后端 未结 3 1905
执笔经年
执笔经年 2021-01-02 11:23

Is there a way to set the general responsive meta viewport () only for phones? We have a website that without that meta tag, zoomed out, looks fine on 7\" and

3条回答
  •  鱼传尺愫
    2021-01-02 12:01

    Do you mean this ?

        
    

    If so, try the following script added in the (taken and adapted from here):

    if(navigator.userAgent.match(/Android/i)
      || navigator.userAgent.match(/webOS/i)
      || navigator.userAgent.match(/iPhone/i)
      || navigator.userAgent.match(/iPad/i)
      || navigator.userAgent.match(/iPod/i)
      || navigator.userAgent.match(/BlackBerry/i)
      || navigator.userAgent.match(/Windows Phone/i)) {
        document.write('');
    }
    

    This will detect if the user-agent indicates that the browser is mobile, and will write that meta viewport as required.

提交回复
热议问题