移动端rem文字自适式
2017-09-06 19:34
183 查看
<script type="text/javascript"> (function (doc, win) { // html var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () { var clientWidth = docEl.clientWidth; if (!clientWidth) return; clientWidth = (clientWidth > 768 ) ? 768 : clientWidth ; docEl.style.fontSize = 10 * (clientWidth / 375 ) + 'px'; }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); recalc(); })(document, window); /*移动端适应大小*/ </script>
<div class="div-1"> ahahhhah </div>
.div-1{ width:250px; height:250px; background-color: red; font-size:1.6rem; }
直接粘贴运行
相关文章推荐
- 移动端开发rem单位的格式化js文件flexible.js
- 移动端布局 - REM方式
- 移动端-rem使用
- 使用rem来开发你的移动端网站
- 移动端(手机)自适应rem布局
- 移动端rem及em
- rem+媒体查询---移动端 设计稿以375
- 移动端自适应布局解决方案——rem
- 解决移动端rem加载瞬间页面错乱的方法(放大或者缩小)
- 移动端网页 rem 自适应布局
- 移动端屏幕自适应js与rem
- 重构技巧三:移动端文字截取后添加三个点的方法,多行处理方式
- 浅谈移动端rem的用法
- rem,移动端适配心得2【转载】
- 移动端设置html的font-size从而设置rem的大小
- 移动端页面使用单位的问题:关于px、百分比、em、rem开发中逐渐转换的问题记录
- 移动端rem自适应方案
- 移动端的适配问题之REM
- rem 移动端适配
- 移动端页面以rem为单位设置字体大小不生效解决方法