支持的设备有:
iOS: iPhone, iPod, iPad
Android: Phones & Tablets
Blackberry: Phones & Tablets
Windows: Phones & Tablets
Firefox OS: Phones & Tablets
使用:在head载入:<script src="device.js"></script>
它会自动在 <html> 标签添加一些设备平台,操作系统,方向相关的 CSS class,这样就能让你针对不同设备撰写不同的 CSS,并且还提供一些 Javascript 函数来判断设备
<html class="ios iphone mobile portrait">
生成的对比CSS Class:
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
Javascript 函数
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()
Test:
<script src="style/js/device.js"></script>
<script>
alert(device.mobile()) //返回true, false,来判断设备
</script>
下载 Device.js
本文介绍Device.js,一个用于检测各种移动设备和桌面设备的轻量级库。支持iOS、Android、BlackBerry、Windows Phone及Firefox OS等系统的手机和平板设备。通过自动添加CSS类和提供JavaScript API帮助开发者轻松实现设备适配。
968

被折叠的 条评论
为什么被折叠?



