aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/overflow-block/index.html
blob: 2112e76e88ce538b304f2ef9643b2ab5b2ad2576 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
title: overflow-block
slug: Web/CSS/overflow-block
translation_of: Web/CSS/overflow-block
---
<p>{{CSSRef}}</p>

<p>The <strong><code>overflow-block</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> property sets what shows when content overflows the block start and block end edges of a box. This may be nothing, a scroll bar, or the overflow content.</p>

<div class="note">
<p>The <code>overflow-block</code> property maps to {{Cssxref("overflow-y")}} or {{Cssxref("overflow-x")}} depending on the writing mode of the document.</p>
</div>

<h2 id="Syntax">Syntax</h2>

<pre class="brush:css no-line-numbers notranslate">/* Keyword values */
overflow-block: visible;
overflow-block: hidden;
overflow-block: scroll;
overflow-block: auto;

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

<p>The <code>overflow-block</code> property is specified as a single keyword chosen from the list of values below.</p>

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

<dl>
 <dt><code>visible</code></dt>
 <dd>Content is not clipped and may be rendered outside the padding box's block start and block end edges.</dd>
 <dt><code>hidden</code></dt>
 <dd>Content is clipped if necessary to fit the block dimension in the padding box. No scrollbars are provided.</dd>
 <dt><code>scroll</code></dt>
 <dd>Content is clipped if necessary to fit in the block dimension in the padding box. Browsers display scrollbars whether or not any content is actually clipped. (This prevents scrollbars from appearing or disappearing when the content changes.) Printers may still print overflowing content.</dd>
 <dt><code>auto</code></dt>
 <dd>Depends on the user agent. If content fits inside the padding box, it looks the same as <code>visible</code>, but still establishes a new block-formatting context. Desktop browsers provide scrollbars if content overflows.</dd>
</dl>

<h2 id="Formal_definition">Formal definition</h2>

<p>{{CSSInfo}}</p>

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

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

<h2 id="Examples">Examples</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html notranslate">&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;overflow-block:hidden&lt;/code&gt; — hides the text outside the box
  &lt;div id="div1"&gt;
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;code&gt;overflow-block:scroll&lt;/code&gt; — always adds a scrollbar
  &lt;div id="div2"&gt;
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;code&gt;overflow-block:visible&lt;/code&gt; — displays the text outside the box if needed
  &lt;div id="div3"&gt;
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    &lt;/div&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;code&gt;overflow-block:auto&lt;/code&gt; — on most browser, equivalent to &lt;code&gt;scroll&lt;/code&gt;
  &lt;div id="div4"&gt;
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css notranslate">#div1,
#div2,
#div3,
#div4 {
  border: 1px solid black;
  width:  250px;
  height: 100px;
}

#div1 { overflow-block: hidden; margin-bottom: 120px;}
#div2 { overflow-block: scroll; margin-bottom: 120px;}
#div3 { overflow-block: visible; margin-bottom: 120px;}
#div4 { overflow-block: auto; margin-bottom: 120px;}
</pre>

<h3 id="Result">Result</h3>

<figure>
<p>{{EmbedLiveSample("Examples", "100%", "780")}}</p>
</figure>

<h2 id="Specifications">Specifications</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('CSS3 Overflow', '#propdef-overflow-block', 'overflow-block') }}</td>
   <td>{{ Spec2('CSS3 Overflow') }}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<div>{{cssinfo}}</div>

<h2 id="Browser_compatibility">Browser compatibility</h2>



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

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

<ul>
 <li>Related CSS properties: {{cssxref("text-overflow")}}, {{cssxref("white-space")}}, {{Cssxref("overflow")}}, {{Cssxref("overflow-inline")}}, {{Cssxref("overflow-x")}}, {{Cssxref("overflow-y")}}, {{Cssxref("clip")}}, {{Cssxref("display")}}</li>
 <li><a href="/en-US/docs/Web/CSS/CSS_Logical_Properties">CSS Logical Properties</a></li>
 <li><a href="/en-US/docs/Web/CSS/CSS_Writing_Modes">Writing Modes</a></li>
</ul>