电脑屏幕适配各尺寸

邮差的信 提交于 2019-12-17 00:49:20
      var width = document.body.offsetWidth;
      switch (true) {
        case width <= 1024:
          el.style.transform = "translate(220px,0)";
          break;
        case width <= 1280  && width >1024:
          el.style.transform = "translate(320px,0)";
          break;
        case width <= 1366 && width >1280:
          el.style.transform = "translate(360px,0)";
          break;
        case width <= 1440 && width >1366:
          el.style.transform = "translate(400px,0)";
          break;
        case width <= 1600 && width >1440:
          el.style.transform = "translate(500px,0)";
          break;
        case width <= 1680 && width >1600:
          el.style.transform = "translate(550px,0)";
          break;
        case width <= 1920 && width >1680:
          el.style.transform = "translate(650px,0)";
          break;
      }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!