Device.js 是一個能夠讓你檢測設備的平臺,操做系統和方向 JavaScript 庫,它會自動在 <html>
標籤添加一些設備平臺,操做系統,方向相關的 CSS class,這樣就能讓你針對不一樣設備撰寫不一樣的 CSS,而且還提供一些 Javascript 函數來判斷設備。css
Device.js 經過操做系統(好比 iOS,安卓,黑莓,Windows,Firefox OX),方向(橫屏或者豎屏),類型(平板或者移動設備),以下面在 iPhone 上的瀏覽的時候在 <html>
添加的 CSS Class:html
Device.js 使用很是簡單,只須要在頁面的 head 載入相關的 JS 庫便可:android
<script src="device.js"></script>
Device | CSS Classes |
---|---|
iPad | ios ipad tablet |
iPhone | ios iphone mobile |
iPod | ios ipod mobile |
Android Phone | android mobile |
Android Tablet | android tablet |
BlackBerry Phone | blackberry mobile |
BlackBerry Tablet | blackberry tablet |
Windows Phone | windows mobile |
Windows Tablet | windows tablet |
Firefox OS Phone | fxos mobile |
Firefox OS Tablet | fxos tablet |
Desktop | desktop |
Orientation | CSS Classes |
---|---|
Landscape | landscape |
Portrait | portrait |
Device | JavaScript Method |
---|---|
Mobile | device.mobile() |
Tablet | device.tablet() |
iOS | device.ios() |
iPad | device.ipad() |
iPhone | device.iphone() |
iPod | device.ipod() |
Android | device.android() |
Android Phone | device.androidPhone() |
Android Tablet | device.androidTablet() |
BlackBerry | device.blackberry() |
BlackBerry Phone | device.blackberryPhone() |
BlackBerry Tablet | device.blackberryTablet() |
Windows | device.windows() |
Windows Phone | device.windowsPhone() |
Windows Tablet | device.windowsTablet() |
Firefox OS | device.fxos() |
Firefox OS Phone | device.fxosPhone() |
Firefox OS Tablet | device.fxosTablet() |
Orientation | JavaScript Method |
---|---|
Landscape | device.landscape() |
Portrait | device.portrait() |
項目主頁:Device.jsios
via wpjamgit