2012-12-18 20 views

回答

1

通過您的Javascript代碼動態加載所需的CSS文檔。

編輯:更復雜的源代碼:

var srcURL; 

if(resolution1) 
    srcURL = "path/small.css"; 
else 
    srcURL = "path/large.css"; 

var style = document.createElement("link") 
style.setAttribute("rel", "stylesheet") 
style.setAttribute("type", "text/css") 
style.setAttribute("href", srcURL) 

document.getElementByTagName("head")[0].appendChild(style); 
+0

是的,那是我的計劃...答案是如何做到這一點-.- – Paedow

+0

在一些JS代碼中編輯。 ;) –

+0

tthats一個不錯的謝謝 – Paedow

4

媒體查詢。

/* your "big screen" CSS here */ 
@media all and (max-width:1024px) { 
    /* your "small screen" CSS here 
} 

您也可以扭轉這種局面,這取決於你要考慮的「默認」的情況下,瀏覽器不支持媒體查詢其中之一:

/* your "small screen" CSS here */ 
@media all and (min-width:1024px) { 
    /* your "big screen" CSS here 
} 
+0

我在哪裏做媒體查詢?在