【推荐】用scss循环zoom缩放比例,解决可视化大屏在不同分辨率屏幕下的适配问题

方法1:

指定几种常规屏幕宽度(用这种方式就必须要强制用户全屏查看页面,在固定的宽度下才能达到比较不错的显示效果)

css 复制代码
// 适配不同分辨率的页面----------------------------------------
html {
  overflow: hidden;
  width: 1920px;
  height: 1080px;
}

$widths: 3840, 3360, 2880, 2560, 2048, 1920, 1680, 1650, 1600, 1440, 1400, 1366, 1360, 1280, 1152, 1024; //屏幕宽度
@for $i from 1 through length($widths) {
  $width: nth($widths, $i);
  @media screen and (max-width: #{$width}px) {
    html {
      zoom: $width / 1920;
    }
  }
}

方法2:

从像素1024循环到2560宽度的情况(会导致很多冗余的css代码,但是基本上所有的宽度情况都囊括了)

css 复制代码
// 适配不同分辨率的页面----------------------------------------
html {
  overflow: hidden;
  width: 1920px;
  height: 1080px;
}

@for $i from 3840 through 1024 {
  $width: $i;
  @media screen and (max-width: #{$width}px) {
    html {
      zoom: $width / 1920;
    }
  }
}
相关推荐
xiAo_Ju2 分钟前
iOS一个Fancy UI的Tricky实现
前端·ios
H***99764 分钟前
Vue深度学习实战
前端·javascript·vue.js
猴猴不是猴33 分钟前
js实现卷轴,中间可滑动方块,左右两侧对比
javascript·css·css3
toooooop841 分钟前
Vuex 中 state、mutations 和 actions 的原理和写法
前端·javascript·uni-app
y***86691 小时前
前端CSS-in-JS方案
前端·javascript·css
暖木生晖1 小时前
APIs之WEB API的基本认知是什么?
前端·dom·dom树·web apis
华仔啊1 小时前
你真的懂递归吗?没那么复杂,但也没那么简单
前端·javascript
火星数据-Tina1 小时前
低成本搭建体育数据中台:一套 API 如何同时支撑比分网与 App?
java·前端·websocket
yddddddy1 小时前
深入浅出前端路由:从概念到实战
前端
林_xi1 小时前
uniapp使用@uni-ku/root插件实现全局组件
前端·uni-app