📜  javascript 轻松调整屏幕大小 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:54.257000             🧑  作者: Mango

代码示例1
//https://cdnjs.cloudflare.com/ajax/libs/enquire.js/2.1.6/enquire.min.js

// this code allows for an Obj instance to run methods on - to call code when a screen change occurs
class ScreenSize{

    addCSS(maxOrMin, screenSize, element, style, change){
     enquire.register("screen and ("+maxOrMin+"-width: "+screenSize+")", ()=>{    
       document.querySelector(element).style[style] = change;
    });
  }
}