aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/overflow-anchor/index.html
blob: 42150355bf154af93e936a11645aa749d29f47b1 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: overflow-anchor
slug: Web/CSS/overflow-anchor
tags:
  - CSS
  - CSS Scroll Anchoring
translation_of: Web/CSS/overflow-anchor
---
<div>{{CSSRef}}</div>

<p><strong><code>overflow-anchor</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> 属性提供一种退出浏览器滚动锚定行为的方法,该行为会调整滚动位置以最大程度地减少内容偏移。</p>

<p>默认情况下,在任何支持滚动锚定行为的浏览器中都将其启用。因此,仅当您在文档或文档的一部分中遇到滚动锚定问题并且需要关闭行为时,才通常需要更改此属性的值。</p>

<h2 id="语法">语法</h2>

<pre class="brush:css no-line-numbers">/* Keyword values */
overflow-anchor: auto;
overflow-anchor: none;

/* Global values */
overflow-anchor: inherit;
overflow-anchor: initial;
overflow-anchor: unset;
</pre>

<h3 id="Values">Values</h3>

<dl>
 <dt><code>auto</code></dt>
 <dd>The element becomes a potential anchor when adjusting scroll position.</dd>
 <dt><code>none</code></dt>
 <dd>The element won't be selected as a potential anchor.</dd>
</dl>

<h3 id="Formal_syntax">Formal syntax</h3>

<pre class="syntaxbox">{{csssyntax}}</pre>

<h2 id="范例">范例</h2>

<p>To prevent scroll anchoring in a document, use the <code>overflow-anchor</code> property.</p>

<pre class="brush: css">body {
  overflow-anchor: none;
}
</pre>

<ul>
</ul>

<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('CSS Scroll Anchoring', '#propdef-overflow-anchor', 'overflow-anchor')}}</td>
   <td>{{Spec2('CSS Scroll Anchoring')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<p>{{cssinfo}}</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("css.properties.overflow-anchor")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/CSS/overflow-anchor/Guide_to_scroll_anchoring">Guide to scroll anchoring</a></li>
</ul>

<div id="gtx-trans" style="position: absolute; left: 385px; top: 1589px;">
<div class="gtx-trans-icon"></div>
</div>