移动页面缩放方法之(三)rem布局
<!DOCTYPE HTML> <html lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/> <title>无标题文档</title> <style> *{ padding:0; margin:0; } body{ background:#000; } div{ width:6.4rem; height:5rem; margin:0 auto; line-height:5rem; font-size:.3rem; text-align:center; color:#fff; background:red; } </style> </head> <body> <div>我是测试的</div> <script> ;!function(top){ var doc=top.document; top.SetSize=function(width){ this.obj=doc.querySelector('html'); this.width=width; this.fontSize=100; this.init().resize(); }; SetSize.prototype={ init:function(){ this.scale=this.obj.clientWidth/this.width; this.obj.setAttribute("style","font-size:"+(this.scale*this.fontSize)+"px !important"); return this; }, resize:function(){ top.addEventListener('resize',this.init.bind(this),false); } }; SetSize.prototype.constructor=SetSize; doc.addEventListener('DOMContentLoaded',function(){ new SetSize(640); },false); }(parent); </script> </body> </html>
移动页面缩放方法之(三)rem布局的更多相关文章
- 移动端(手机端)页面自适应解决方案1(rem布局)---750设计稿
设计稿尺寸为750 * 1340.结合网易.淘宝移动端首页html元素上的动态font-size属性.设计稿尺寸.前端与设计之间协作流程一般分为下面两种: 网易做法: 页面开头处引入下面这段代码,用于 ...
- 移动页面缩放方法之(二)控制HTML
<!DOCTYPE HTML> <html lang="zh-cn"> <head> <meta http-equiv="Con ...
- 移动页面缩放方法之(一)控制meta法
<!DOCTYPE HTML> <html lang="zh-cn"> <head> <meta http-equiv="Con ...
- CSS实现三列布局
三列布局指的是两边两列定宽,中间的宽度自适应. 常用三种方法: 定位 浮动 弹性盒布局 定位方式 最直观和容易理解的一种方法,左右两栏选择绝对定位,固定于页面的两侧,中间的主体选择用margin确定位 ...
- 移动端rem布局实现(vw)
什么是rem?在W3C官网上是这样描述的:“font size of the root element (根元素的字体大小)”.就是说rem是相当于html的,因为网页的默认字体大小是 16px,所以 ...
- H5 页面 rem 布局适配方法
rem 布局适配方案 主要方法为: 按照设计稿与设备宽度的比例,动态计算并设置 html 根标签的 font-size 大小: css 中,设计稿元素的宽.高.相对位置等取值,按照同等比例换算为 re ...
- 手机端页面自适应:rem布局
rem布局非常简单,首页你只需在页面引入这段原生js代码就可以了 (function (doc, win) { var docEl = doc.documentElement, resizeEvt = ...
- 手机端页面自适应解决方案—rem布局进阶版
手机端页面自适应解决方案—rem布局进阶版 https://www.jianshu.com/p/985d26b40199 注:本文转载之处:https://www.cnblogs.com/anni ...
- 手机端页面自适应解决方案—rem布局(进阶版,附源码示例)
转自:https://segmentfault.com/a/1190000007350680 一年前笔者写了一篇 <手机端页面自适应解决方案—rem布局>,意外受到很多朋友的关注和喜欢.但 ...
随机推荐
- 欧拉计划(1~3)ps:以后看题一定要认真
那天的题挺简单的 下面来看下 No1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get ...
- Python 日期格式化 及 schwartzian排序
__author__ = 'root' import datetime import time import copy # 12/Dec/2012:23:59:50 # 12/Sep/2012:23: ...
- WEB工程数据库相关安装脚本写作
1. 数据库oracle安装 2. 数据库用户创建,表空间创建,表创建 #!/bin/bash current_path=`pwd` create_tablespace=${current_path} ...
- js/bat批处理调用谷歌浏览器chrome批量打开网页测试web性能
批处理批量打开网页 其实用java就可以搞定,但是这么一个轻巧的测试,js或者bat批处理去一次性打开几百个网页测试一下页面没必要上java 两者的区别,js的话,只能打开多个浏览器实例,不方便查看效 ...
- HYPER-V2008里安装WINDOWS 2012,以及监控宝
呵呵,这两者有关系么?没关系.哈哈. 为了方便就放一起了. 至少,2008里的HYPERV能安装2012,倒是给我很多欣慰.
- angularjs学习总结(~~很详细的教程)
1 前言 前端技术的发展是如此之快,各种优秀技术.优秀框架的出现简直让人目不暇接,紧跟时代潮流,学习掌握新知识自然是不敢怠慢. AngularJS是google在维护,其在国外已经十分火热,可是国内的 ...
- struts2 Convention插件零配置,使用注解开发
从struts21开始,struts2不再推荐使用codebehind作为零配置插件,而是改用Convention插件来支持零配置.与以前相比较,Convention插件更彻底. 使用Conventi ...
- 【HDOJ】2405 Marbles in Three Baskets
BFS+状态压缩. /* 2405 */ #include <iostream> #include <queue> #include <cstdio> #inclu ...
- window7 64位安装Python
Python下载地址:https://www.python.org/download/releases/2.7.8/ 选择64位的安装,然后双击打开下载的文件,默认一步步安装. 其中有一个步骤如下图: ...
- a trick in reading and storing file in the exact way!
read and write file is a very common operation regarding file mainuplation. However, the powerfull g ...