rem布局计算(移动端,pc端有兼容性)
2024-10-20 00:21:24
1 <!DOCTYPE html>
2 <html>
3 <head lang="en">
4 <script>
5 function rootREM() {
6 var W = document.documentElement.clientWidth;
7 W = (W <= 640) ? W : 640;
8 document.documentElement.style.fontSize = W / 10 + 'px';
9 document.body.style.fontSize = W / 20 + 'px';
10 }
11 window.onresize = function () {
12 rootREM()
13 };
14 </script>
15 <meta charset="UTF-8">
16 <title></title>
17 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
18 </head>
19 <body onload="rootREM()">
20
21 <div style="max-width: 640px;">
22 <br/>你好,世界!
23 <br/>你好,世界!
24 <br/>你好,世界!
25 <br/>你好,世界!
26 <br/>你好,世界!
27 <br/>你好,世界!
28 <br/>你好,世界!
29 <br/>你好,世界!
30 <br/>你好,世界!
31 <br/>你好,世界!
32 <br/>你好,世界!
33 <br/>你好,世界!
34 <br/>你好,世界!
35 <br/>你好,世界!
36 <br/>你好,世界!
37 <br/>你好,世界!
38 <br/>你好,世界!
39 <br/>你好,世界!
40 <br/>你好,世界!
41 <br/>你好,世界!
42 <br/>你好,世界!
43 <br/>你好,世界!
44 <br/>你好,世界!
45
46 </div>
47
48 </body>
49 </html>
最新文章
- Codeforces Round #257 (Div. 2)
- [异常解决] JTAG 与STM32的SWD连接接线方式
- EasyUI中Dialog的使用
- 【XLL API 函数】 xlDefineBinaryName
- 一个简单的 ASP.NET MVC 例子演示如何在 Knockout JS 的配合下,使用 TypeScript 。
- struts2视频学习笔记 01-02
- Milk Patterns - poj 3261 (求重复k次的最长子串)
- CSS3知识点整理(四)----布局样式及其他
- hibernate exception nested transactions not supported 解决方法
- <;p>;<;/p>;标签为什么不能包含块级标签?还有哪些特殊的HTML标签?
- python笔记一(正则表达式)
- 测试驱动开发实践2————从testList开始
- SSM-SpringMVC-22:SpringMVC中转发(forward)和重定向(redirect)
- ES6教程-字符串,函数的参数,了解函数的arguments对象,js面向对象,设计模式-单例模式,解构赋值
- MongoDB的地理位置查询,以及和mysql的使用对比
- 何凯文每日一句||DAY10
- CAS (7) —— Mac下配置CAS 4.x的JPATicketRegistry(服务端)
- 浅谈原始套接字 SOCK_RAW 的内幕及其应用(port scan, packet sniffer, syn flood, icmp flood)
- scala(9) Monad
- BD09坐标(百度坐标) WGS84(GPS坐标) GCJ02(国测局坐标) 的相互转换
热门文章
- linux解决“XXX is not in the sudoers file”错误
- mac安装thrift
- 五年屌丝运维工作shell精华
- java 实现唯一ID生成器
- Linux基本数据类型大小——int,char,long int,long long int
- openstack neutron 深入
- MySQL USING 和 HAVING 用法
- easyui datagrid checkbox选中事件
- 全面拥抱移动测试,Mobile JSON Wire Protocol Specification文档翻译
- 类名.class和getClass()区别