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

Application of rem layout in JavaScript in react_javascript skills

WBOY
Release: 2016-05-16 15:26:55
Original
2049 people have browsed it

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();
  }); 
Copy after login

sass:

$baseFontSize:16px !default;
// pixels to rems 
@function pxToRem($px) {
  @return $px / $baseFontSize * 1rem;
}
html {
 font-size: $baseFontSize;
 -ms-touch-action: none;
}
Copy after login
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template