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;
}
来源:CSDN
作者:叶川飞流
链接:https://blog.csdn.net/weixin_41033048/article/details/103569358