H5 page response adaptation

Multi adapt layout

In order to achieve a page can serve as a friendly display multiport adapt, usually developed before the project will be based on the needs of a good way to confirm the layout of the page.

```

// js来监听视口的变化 来修改根元素(html)的大小
!(function(doc, win) {
var docEle = doc.documentElement,
evt = "onorientationchange" in window ? "orientationchange" : "resize",
fn = function() {
var width = docEle.clientWidth;
width = width < 320 ? 320 : width;
width = width > 640 ? 640 : width;
width && (docEle.style.fontSize = 100 * (width / 640) + "px");
};

win.addEventListener(evt, fn, false);
doc.addEventListener("DOMContentLoaded", fn, false);

}(document, window));
```

Guess you like

Origin www.cnblogs.com/linsxl/p/11698506.html