網站首頁 編程語言 正文
<!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
相關推薦
- 2023-03-26 python命令行參數argparse模塊基本用法詳解_python
- 2022-06-10 ASP.NET?Core使用AutoMapper組件_實用技巧
- 2023-01-07 python導入其他目錄下模塊的四種情況_python
- 2023-01-02 Android?數據結構全面總結分析_Android
- 2022-03-27 centos7安裝mongo數據庫的方法(mongo4.2.8)_MongoDB
- 2024-03-01 【Promise】promise關鍵問題和解決辦法
- 2022-09-09 python處理xml文件操作詳解_python
- 2022-10-17 C#使用集合實現二叉查找樹_C#教程
- 最近更新
-
- 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同步修改后的遠程分支