/ / less file

// define the variable @rem: 375/16rem;

  • { padding: 0; margin: 0; }

html { font-size: 100/@rem; }

body { font-size: 18/@rem; }

.app { background-color: pink; width: 375/@rem; height: 300/@rem; }

Nihao </div> <div> basdbbasdb </div> js (function() {// calculate screen width var vW = document.documentElement.clientWidth; Var w = vw/16; / / set the font size of the root document. The documentElement. Style.css. FontSize = w + 'px'; }) ()Copy the code