Mobile terminal adaptive code

(function(doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = “orientationchange” in window ? “orientationchange” : “resize”,
    recalc = function() {
      var clientWidth = docEl.clientWidth;
      if (!clientWidth) return; = 100 * (clientWidth / 750) + “px”;
  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener(“DOMContentLoaded”, recalc, false);
})(document, window);

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]