網站首頁 編程語言 正文
<!DOCTYPE html> <html> ? <head> ? ? <meta charset="utf-8"> ? ? <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"> ? ? <title>test</title> ? </head> ? <script> ? ?window.onload = function () { ? ? ? getRem(750, 100) //設計圖紙的屏幕的寬度,rem的計算值 ? ? }; ? ? window.onresize = function () {//設計圖紙的屏幕的寬度,rem的計算值 ? ? ? getRem(750, 100) ? ? }; ? ? function getRem(pwidth, prem) { ? ? ? var html = document.getElementsByTagName("html")[0];//獲取整體頁面的html標簽 ? ? ? var oWidth = document.body.clientWidth || document.documentElement.clientWidth;//獲取當前屏幕寬度 ? ? ? html.style.fontSize = oWidth / pwidth * prem + "px"; //按照計算1rem等于這里得整合 ? ? } ? </script> ? <body> ? ? <div id="app-box"> ?? ??? ?<div class="daad">111111</div> ?? ?</div> ? </body> ? <style> ? .daad{ ? ?width:1rem; /*根據設計圖測量的數值除以上面定的比如100就得到了rem */ ? ?font-size:0.2rem; ? ?background:red; ? } ? </style> </html>
原文鏈接:https://blog.csdn.net/u012834688/article/details/122358300
相關推薦
- 2022-02-17 H5移動端點擊出現背景藍色框的解決方案
- 2022-07-03 YOLOv5中SPP/SPPF結構源碼詳析(內含注釋分析)_python
- 2022-03-14 easypoi導入校驗跳過空行_EasyPoi導入驗證功能
- 2022-07-14 Python中添加搜索路徑的方法實例_python
- 2023-07-09 echart 設置柱狀圖y軸最大刻度
- 2021-12-14 RHCE橋接,免密登錄和修改端口號介紹_Linux
- 2022-02-17 React + TS 完成 TodoList
- 2022-06-30 Python使用Pillow添加水印_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支