源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JavaScript中rem布局在react中的应用

  • 时间:2022-11-15 10:11 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JavaScript中rem布局在react中的应用
前面给大家分享了一个react项目([url=http://www.1sucai.cn/article/76085.htm]http://www.1sucai.cn/article/76085.htm[/url]),这次对这个项目做了一些改进,增加了rem布局和对iscroll在Android上的优化。 [url=https://github.com/baixuexiyang/react]项目代码[/url],欢迎fork和star,[url=http://baixuexiyang.github.io/react/]在线预览[/url] [b]REM布局实例代码[/b]
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();
  }); 
[b]sass:[/b]
$baseFontSize:16px !default;
// pixels to rems 
@function pxToRem($px) {
  @return $px / $baseFontSize * 1rem;
}
html {
 font-size: $baseFontSize;
 -ms-touch-action: none;
}
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部