I recently developed a mobile website and encountered some problems when using viewport
.
After many attempts, the current situation is that UC, Chrome, and Android automatically With the browser and safari, the viewport can be displayed according to the zoom ratio as expected.
However, in the QQ browser, which has a huge number of users, it seems that the viewport cannot be recognized (or cannot be used).
The code is as follows: HTML<meta id="viewport" content=" target-densitydpi=device-dpi, user-scalable=no, width=device-width, initial-scale=0.5" name="viewport" />
var viewPortScale; var dpr = window.devicePixelRatio; if(dpr <= 2) { viewPortScale = 1 / window.devicePixelRatio; } else { viewPortScale = 0.5 } document.getElementById('viewport').setAttribute( 'content', 'user-scalable=no, width=device-width, initial-scale=' + viewPortScale); // alert(viewPortScale);