惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
小众软件
小众软件
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
B
Blog
量子位
B
Blog RSS Feed
Vercel News
Vercel News
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
Jina AI
Jina AI
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG

博客园 - ^Mao^

不同缩放下适配 vxe-table 3D饼图 openlayer实现给线的附近添加点,点支持移动 element-plus el-select html导出pdf openlayers增加移动功能 部分页面统计用户访问时长 openlayers基本使用(街景+标注+绘制) 使用openlayer绘制街景地图 正则表达式--取对应表达式的值 vue2实现el-table-column多级效果 echarts-雷达图 echarts--地图 散点图效果 echarts散点图区域设置 vant 的vant-uploader组件问题 Threejs学习 Echarts-普通地图和3D地图实现 test
适配
^Mao^ · 2025-11-08 · via 博客园 - ^Mao^

前端代码适配层面

  • 使用 Viewport 适配:在网页头部引入代码,其中width=device-width表示将 viewport 的宽度设置为设备的宽度,initial-scale=1.0表示初始缩放比例为 1.0,不进行缩放,user-scalable=no表示用户不可以通过手动缩放页面,这样可以避免屏幕缩放对页面布局的影响。
  • 使用媒体查询:通过媒体查询针对不同屏幕尺寸或页面缩放程度来确定不同的样式。例如,根据便携电脑缩放 150% 时的网页可见宽度作为依据,设置不同的 CSS 样式,如@media all and (-webkit - min - device - pixel - ratio: 1.41) and (-webkit - max - device - pixel - ratio: 1.6), (min - resolution: 1.41dppx) and (max - resolution: 1.6dppx) {body {font - size: 10px;}},来调整网页元素的大小和布局。
  • JavaScript 代码适配:可以在网页尾部的前加入以下 JavaScript 代码,根据屏幕像素比自动设置网页的 zoom 缩放比例。
<script>
const t = window.devicePixelRatio;
let zoom = 1;
if (t!== 1) {
zoom = (1 / t) * zoom;
}
document.body.style.zoom = zoom;
</script>