<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <!-- <meta name="viewport" content="width=device-width,initial-scale=.33333,minimum-scale=.33333,maximum-scale=.33333" /> --> <script> //获取像素比 //console.log(window.devicePixelRatio); var pixelRatio = 1 / window.devicePixelRatio; console.log(pixelRatio); //通过js动态设置视口(viewport) document.write(‘<meta name="viewport" content="width=device-width,initial-scale=‘+pixelRatio+‘,minimum-scale=‘+pixelRatio+‘,maximum-scale=‘+pixelRatio+‘" />‘); </script> </head> <body> </body> </html>