多屏判斷css改寫

allexwang發表於2015-05-27
 1 function replaceBodyClass(){
 2     for(var i in map){
 3        if(map[i](width)){
 4           document.body.className = document.body.className.replace(/screen-\w+/, "screen-"+i)
 5           break
 6        }
 7     }
 8 }
 9 
10 map["1280"] = function(width){
11    return width <= 1300
12 }
13 
14 
15 map["x1"] = function(width){
16    return width > = 1580
17 }
18 
19 map["1"] = function(width){
20    return  width > = 1400 && width < 1580
21 }

相關文章