echars适配代码
$(function(){ var evt = "onorientationchange" in window ? "orientationchange" : "resize"; var zx_win_resie = function(){ var _w = window.innerWidth, _h = window.innerHeight, _c = 1, _cw= 1, _ch= 1, wb = $('body').attr('width'), hb = $('body').attr('height'); if (_w/_h > (wb/hb)) { _c = _h/hb; }else{ _c = _w/wb; } var _t = -((1-_c)/(2*_c))*100; if (_w/_h > (wb/hb)) { _ch = _t; _cw = _t + ((_w - wb*_c)*50 / (wb*_c)); }else{ _ch = _t + ((_h - hb*_c)*50 / (hb*_c)); _cw = _t; } $('body').css({'transform':'scale('+_c+') translate('+_cw+'%, '+_ch+'%)'}); } window.addEventListener(evt, function() { setTimeout(function(){ zx_win_resie();}, 300); }, false) zx_win_resie(); })
在需要的页面直接引入这段代码
<script src="js/index.js"></script> 设置body <body width="1920" height="1080"></body>