--- title: overflow-x slug: Web/CSS/overflow-x translation_of: Web/CSS/overflow-x --- <p>{{ CSSRef() }}</p> <p>{{ SeeCompatTable() }}</p> <h2 id="Summary" name="Summary">概述</h2> <p><span style="line-height: inherit;">当一个块级元素的内容在水平方向发生溢出时,</span><a href="/en/CSS" style="line-height: inherit;" title="CSS">CSS</a><span style="line-height: inherit;">属性</span><span style="font-family: courier new,andale mono,monospace; line-height: inherit;">overflow-x</span><span style="line-height: inherit;">决定应该截断溢出内容,或者显示滚动条,或者直接显示溢出内容</span><span style="line-height: inherit;">。</span></p> <p>{{cssinfo}}</p> <h2 id="Syntax" name="Syntax">用法</h2> <pre class="twopartsyntaxbox"><a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">合法值</a>: {{csssyntax("overflow-x")}} </pre> <pre>overflow-x: visible overflow-x: hidden overflow-x: scroll overflow-x: auto overflow-x: inherit </pre> <h3 id="Values" name="Values">解释</h3> <dl> <dt><code>visible</code></dt> <dd>内容不会被截断,且可以显示在内容盒之外。</dd> <dt><code>hidden</code></dt> <dd>内容会被截断,且不会显示滚动条。</dd> <dt><code>scroll</code></dt> <dd>桌面浏览器总是显示滚动条,无论内容是否发生溢出。这可以避免滚动条的显示与消失所导致的元素尺寸不确定的问题。而打印机可能会打印溢出的内容。</dd> <dt><code>auto</code></dt> <dd>取决于浏览器本身。当内容发生溢出时,桌面浏览器如Firefox会显示滚动条。</dd> </dl> <h2 id="Examples" name="Examples">示例</h2> <pre class="eval">[fixme] </pre> <h2 id="Specifications" name="Specifications">规范</h2> <table class="standard-table"> <thead> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">备注 </th> </tr> </thead> <tbody> <tr> <td>{{ SpecName('CSS3 Box', '#overflow-x', 'overflow-x') }}</td> <td>{{ Spec2('CSS3 Box') }}</td> <td></td> </tr> </tbody> </table> <h2 id="Browser_compatibility" name="Browser_compatibility">浏览器支持</h2> <p>{{Compat("css.properties.overflow-x")}}</p> <h2 id="See_also" name="See_also">参见</h2> <ul> <li>相关CSS属性: {{ cssxref("text-overflow") }}, {{ cssxref("white-space") }}, {{ Cssxref("overflow") }}, {{ Cssxref("overflow-y") }}, {{ Cssxref("clip") }}, {{ Cssxref("display") }}</li> </ul>