SoFunction
Updated on 2025-04-07

Application of rem layout in react in JavaScript

I shared a react project with you earlier (https:///article/), this time, some improvements were made to this project, adding rem layout and optimization of iscroll on Android.

Project Code, welcome fork and star,Online preview

REM layout instance code

var fontSizeInit = function() {
  var doc = ,
   cli = ;
  cli&&(cli/=320,2<cli&&(cli=2),=16*cli+"px");
 }
fontSizeInit();
  ('resize', function() {
   fontSizeInit();
  }); 

sass:

$baseFontSize:16px !default;
// pixels to rems 
@function pxToRem($px) {
  @return $px / $baseFontSize * 1rem;
}
html {
 font-size: $baseFontSize;
 -ms-touch-action: none;
}