Force mobile browser zoom out with Javascript

前端 未结 5 1793
名媛妹妹
名媛妹妹 2020-12-03 17:26

In my web app, I have some thumbnails that open a lightbox when clicked. On mobile, the thumbnails are small and the user typically zooms in. The problem is that when they c

5条回答
  •  甜味超标
    2020-12-03 18:15

    This one works for me

    let sw = window.innerWidth;
    let bw = $('body').width();
    let ratio = sw / bw - 0.01;
    $('html').css('zoom', ratio);
    $('html').css('overflow-x', 'hidden');
    

    Its fits html to screen and prevents from scrolling. But this is not a good idea and work not everywhere.

提交回复
热议问题