2013-02-15 22 views

回答

1
if(navigator.userAgent.match(/Android/i){ 
     //apply style to element 
}else if (navigator.userAgent.match(/iPhone/i)){ 
     //apply style to element 
}else if (navigator.userAgent.match(/iPad/i)){ 
     //apply style to element 
} 
1

正確的方法是通過純CSS的媒體類型。這是響應列表視圖的一個活生生的例子,它的寬度是屏幕寬度determinated:

ul { 
float: left; width: 100% !important; 
} 

/* iPhone Horizontal -------------------*/ 
@media all and (min-width: 480px){ 
ul { width: 100% !important; } 
}  

/* iPad Verticle -----------------------*/ 
@media only screen and (min-width: 768px) { 
ul { width: 50% !important; } 
} 

/* iPad Horizontal ---------------------*/ 
@media only screen and (min-width: 1024px) {  
ul { width: 50% !important; } 
} 

/* Nexus 7 Horizontal ------------------*/ 
@media only screen and (min-width: 1280px) {  
ul { width: 33.3333333% !important; } 
} 

/* Laptop 1440 -------------------------*/ 
@media only screen and (min-width: 1440px) {  
ul { width: 33.3333333% !important; } 
} 

/* Monitor 1600 ------------------------*/ 
@media only screen and (min-width: 1600px) { 
ul { width: 25% !important; } 
} 

/* Monitor 1920 ------------------------*/ 
@media only screen and (min-width: 1920px) {  
ul { width: 20% !important; } 
} 

而且這裏有一個工作的jsfiddle例如:http://jsfiddle.net/Gajotres/Yz3nS/,用它來解決您的按鈕。

編輯:

這裏是爲你工作的jsfiddle例如:http://jsfiddle.net/Gajotres/vjsua/,你應該調整一個結果區,看到有差別。

+0

你想讓我爲你創造一個實例嗎? – Gajotres 2013-02-21 08:31:50

+0

是的這將是非常有幫助 – user2074601 2013-02-22 12:03:03