首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

指针 | @media.pointer

@media.pointer

可以使用指针CSS @media媒体功能,根据用户的主要输入机制是否为一个指向设备来应用样式,如果是,它将十分准确。

语法

pointer功能被指定为从下面的列表中选择的关键字值。

none主要输入机制不包括指点设备。

coarse主要输入机制包括精度有限的定点设备。

fine主要的输入机制包括一个精确的指针设备。

例子

HTML

代码语言:javascript
复制
<input id="test" type="checkbox" />
<label for="test">Look at me!</label>

CSS

代码语言:javascript
复制
input[type="checkbox"]:checked {
  background: gray;
}

@media (pointer: fine) {
  input[type="checkbox"] {
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border: 1px solid blue;
  }
}

@media (pointer: coarse) {
  input[type="checkbox"] {
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border: 2px solid red;
  }
}

结果

规范

Specification

Status

Comment

Media Queries Level 4The definition of 'pointer' in that specification.

Working Draft

Initial definition.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Edge

Internet Explorer

Opera

Safari

Basic support

41

No support2

20 or earlier (12)

Nightly build

28

9.0 1

Feature

Android

Chrome for Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

No support

50

No support2

36

?

9.2

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com