如果js设置移动端有两种方式 大家可以参考
//使用em单位 var scaleObj = { documentEle : document.documentElement, deviceWidth : document.documentElement.clientWidth, scale : 0, resetPage : function(){ this.scale = this.deviceWidth/6.4; this.documentEle.style.fontSize = this.scale + 'px'; }, init :function(falseCode){ this.ChangeDevW(); this.deviceWidth < 640 ? this.resetPage() : falseCode; }, ChangeDevW : function(){ this.deviceWidth = this.documentEle.clientWidth; } }; window.onload = function(){ scaleObj.init(false); } window.onresize = function(){ scaleObj.init(scaleObj.documentEle.style.fontSize = 625 + '%'); }; //使用px单位 var vieWport = { phoneWidth : parseInt(window.screen.width), phoneScale : this.phoneWidth / 640, ua : navigator.userAgent, init : function(){ if (/Android (\d+\.\d+)/.test(this.ua)) { var version = parseFloat(RegExp.$1); if (version > 2.3) { document.write('<meta name="viewport" content="width=640, initial-scale= ' + this.phoneScale + ' ,minimum-scale = ' + this.phoneScale + ', maximum-scale = ' + this.phoneScale + ', target-densitydpi=device-dpi">') } else { document.write('<meta name="viewport" content="width=640, initial-scale= ' + this.phoneScale + ' , target-densitydpi=device-dpi">') } } else { document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">') } } } vieWport.init();