blob: 14c44ff8f7c32e8a5a3be5fb605baf7f003bf86b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
---
title: hover
slug: Web/CSS/@media/hover
tags:
- '@media'
- CSS
- Reference
- media feature
translation_of: Web/CSS/@media/hover
---
<div>{{cssref}}</div>
<p>该<strong><code>hover</code></strong> <a href="/en-US/docs/CSS">CSS</a> {{cssxref("@media")}} 可以根据用户的主要输入机制是否可以悬停在元素之上来应用样式。</p>
<h2 id="语法">语法</h2>
<p>悬停功能指定为从下面列表中选择的关键字值。</p>
<dl>
<dt><code>none</code></dt>
<dd>主要输入机制无法悬停或不方便悬停(例如,当用户执行不方便的长按操作时,许多移动设备模拟悬停),或者没有主指示输入机制。</dd>
<dt><code>hover</code></dt>
<dd>主要输入机制可以方便地悬停在元素上。</dd>
</dl>
<h2 id="例子">例子</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: html"><a href="#">Try hovering over me!</a></pre>
<h3 id="CSS">CSS</h3>
<pre class="brush: css">@media (hover: hover) {
a:hover {
background: yellow;
}
}</pre>
<h3 id="结果">结果</h3>
<p>{{EmbedLiveSample("Example")}}</p>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('CSS4 Media Queries', '#hover', 'hover')}}</td>
<td>{{Spec2('CSS4 Media Queries')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
<p>{{Compat("css.at-rules.media.hover")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/CSS/@media/any-hover">the <code>any-hover</code> media feature</a></li>
</ul>
|