html5布局适配rem
2016-10-08 13:56
190 查看
css实现方法:
js实现方法:
html { font-size : 20px; } @media only screen and (min-width: 401px){ html { font-size: 25px !important; } } @media only screen and (min-width: 428px){ html { font-size: 26.75px !important; } } @media only screen and (min-width: 481px){ html { font-size: 30px !important; } } @media only screen and (min-width: 569px){ html { font-size: 35px !important; } } @media only screen and (min-width: 641px){ html { font-size: 40px !important; } }
js实现方法:
/** * [以iPhone6的设计稿为例js动态设置文档 rem 值] * @param {[type]} currClientWidth [当前客户端的宽度] * @param {[type]} fontValue [计算后的 fontvalue值] * @return {[type]} [description] */ <script> var currClientWidth, fontValue,originWidth; //originWidth用来设置设计稿原型的屏幕宽度(这里是以 Iphone 6为原型的设计稿) originWidth=375; __resize(); //注册 resize事件 window.addEventListener('resize', __resize, false); function __resize() { currClientWidth = document.documentElement.clientWidth; //这里是设置屏幕的最大和最小值时候给一个默认值 if (currClientWidth > 640) currClientWidth = 640; if (currClientWidth < 320) currClientWidth = 320; // fontValue = ((62.5 * currClientWidth) /originWidth).toFixed(2); document.documentElement.style.fontSize = fontValue + '%'; } </script>
相关文章推荐
- HTML5实现移动端之-rem布局
- (淘宝无限适配)手机端rem布局详解
- 【web】强大的屏幕适配布局rem响应式 实现一套web代码多端自适应适配
- 30行js让你的rem弹性布局适配所有分辨率(含竖屏适配)(转载)
- Flexible实现H5页面的rem布局适配
- 使用rem实现全屏幕自动适配(等比例缩放布局样式)
- (淘宝无限适配)手机端rem布局详解(转载非原创)
- 30行js让你的rem弹性布局适配所有分辨率(含竖屏适配)
- js让你的rem弹性布局适配所有分辨率(含竖屏适配)
- html5新的度量单位rem 更完美适配
- HTML5 自适应rem布局
- 移动端适配不同手机 rem布局
- rem - 移动前端自适应适配布局解决方案和比较(转载)
- 手机端rem布局详解(淘宝无限适配)
- 手机端rem布局详解(淘宝无限适配)
- 更新 手淘 flexible 布局 rem 单位适配问题
- html5移动端适配使用流体布局经常遇到的坑
- (淘宝无限适配)手机端rem布局
- 移动端适配以及百分比布局与rem比较
- Html5移动端页面自适应布局详解(阿里rem布局)