Home  >  Article  >  Web Front-end  >  Application of rem layout in JavaScript in react_javascript skills

Application of rem layout in JavaScript in react_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:26:551985browse

I shared a react project with you earlier (http://www.jb51.net/article/76085.htm). This time I have made some improvements to the project, adding rem layout and Optimization of iscroll on Android.

Project code, welcome to fork and star, online preview

REM layout example code

var fontSizeInit = function() {
  var doc = document.documentElement,
   cli = doc.clientWidth;
  cli&&(cli/=320,2<cli&&(cli=2),doc.style.fontSize=16*cli+"px");
 }
fontSizeInit();
  window.addEventListener('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;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn