zoukankan      html  css  js  c++  java
  • Device.js——检测设备平台、操作系统的Javascript 库

    http://segmentfault.com/a/1190000000373735

    Device.js 是一个可以让你检测设备的平台,操作系统和方向 JavaScript 库,它会自动在 <html> 标签添加一些设备平台,操作系统,方向相关的 CSS class,这样就能让你针对不同设备撰写不同的 CSS,并且还提供一些 Javascript 函数来判断设备。

    Device.js

    Device.js 通过操作系统(比如 iOS,安卓,黑莓,Windows,Firefox OX),方向(横屏或者竖屏),类型(平板或者移动设备),如下面在 iPhone 上的浏览的时候在 <html> 添加的 CSS Class:

    Device.js 添加的 CSS Class

    支持的设备

    • iOS: iPhone, iPod, iPad
    • Android: Phones & Tablets
    • Blackberry: Phones & Tablets
    • Windows: Phones & Tablets
    • Firefox OS: Phones & Tablets

    如何使用

    Device.js 使用非常简单,只需要在页面的 head 载入相关的 JS 库即可:

    <script src="device.js"></script>
    

    生成的 CSS Class:

    DeviceCSS 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
    OrientationCSS Classes
    Landscape landscape
    Portrait portrait

    相关的 Javascript 函数

    DeviceJavaScript 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()
    OrientationJavaScript Method
    Landscape device.landscape()
    Portrait device.portrait()

    项目主页:Device.js

     

    https://github.com/matthewhudson/device.js

     

     

  • 相关阅读:
    质数检测器
    《视觉SLAM十四讲》学习日志(一)——预备知识
    C++类的介绍
    Python数据类型解析(基础篇)
    括号匹配详解
    哈夫曼树编码
    分治之归并,快速排序
    洛谷p2216 多次单调队列,扫描矩阵中的最大值减去最小值最的固定大小子矩阵
    洛谷p1886滑动窗口最大最小值 双单调队列
    洛谷p1725 露琪诺 单调队列优化的DP
  • 原文地址:https://www.cnblogs.com/carlo/p/4319516.html
Copyright © 2011-2022 走看看