1.
(function (doc, win) {
? var docEl = doc.documentElement,
? ? ? resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
? ? ? recalc = function () {
? ? ? var clientWidth = docEl.clientWidth;
? ? ? if (!clientWidth) return;
? ? ? docEl.style.fontSize = (clientWidth / 15) * 4 + 'px';
? ? ? };
? if (!doc.addEventListener) return;
? win.addEventListener(resizeEvt, recalc, false);
? doc.addEventListener('DOMContentLoaded', recalc, false);
? })(document, window);
2.
<script>
? ? ? ? var initHandle = function() {
? ? ? ? ? ? function Rem() {
? ? ? ? ? ? ? ? if (document.documentElement.clientWidth <= 320) {
? ? ? ? ? ? ? ? ? ? document.documentElement.style.width = 320 + "px";
? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? var rem = document.documentElement.clientWidth / 7.5;
? ? ? ? ? ? ? ? ? ? document.documentElement.style.fontSize = rem + 'px';
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? var Dw = document.documentElement.clientWidth
? ? ? ? ? ? if (Dw <= 750) {
? ? ? ? ? ? ? ? Rem()
? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? document.documentElement.style.fontSize = '16px';
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? initHandle()
? ? ? ? window.onresize = function() {
? ? ? ? ? ? initHandle()
? ? ? ? }
? ? </script>
3.連接flexible.js
<script src="../libs/flexible.js"></script>
4.
<script>
? ? ? ? var reg = document.documentElement.clientWidth;
? ? ? ? document.documentElement.style.fontSize = 100 * reg / 750 + "px"
? ? </script>
? ? <style>
? ? ? ? * {
? ? ? ? ? ? font-size: .14rem;
? ? ? ? }
? ? </style>