//防止屏幕滑动 $(window).on('scroll.elasticity', function (e) { e.preventDefault(); }).on('touchmove.elasticity', function (e) { e.preventDefault(); }); //重设字体大小 var _resizeFromFont = function () { $('.content-form>form').each(function () { $(this).css('font-size', $(this).width() * 0.04); }); } $(window).resize(function () { _resizeFromFont(); }); _resizeFromFont();
使用时,css文件中使用em单位,例如font-size: 1em;