Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting overflow-x: hidden adds a vertical scrollbar
    primarykey
    data
    text
    <p>When I specify <code>overflow-x: hidden</code> on an element which overflows both horizontally and vertically, the element gets a vertical scroll bar in addition to hiding the horizontally overflowing content. I have tried adding <code>overflow-y: visible</code> and even just <code>overflow: visible</code>, to no effect.</p> <p>Am I misunderstanding what these properties do? I would think that <code>overflow-x</code> should not affect the vertical overflow at all.</p> <p>This has happened on every browser I've tried.</p> <p>Here's a snippet which demonstrates the effect. I'm using <code>&lt;pre&gt;</code> tags because they're an easy way to create overflowing content, but it seems to happen with any tag.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>pre { height: 40px; width: 150px; margin-bottom: 50px; /* We need this so they don't overlap. */ } #x-hidden { overflow-x: hidden; } #y-visible { overflow-x: hidden; overflow-y: visible; } #visible { overflow: visible; overflow-x: hidden; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;pre&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum lorem felis, sit amet sodales nunc gravida eget. Integer mollis quis magna quis vulputate. Cras aliquet convallis efficitur. &lt;/pre&gt; &lt;pre id="x-hidden"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum lorem felis, sit amet sodales nunc gravida eget. Integer mollis quis magna quis vulputate. Cras aliquet convallis efficitur. &lt;/pre&gt; &lt;pre id="y-visible"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum lorem felis, sit amet sodales nunc gravida eget. Integer mollis quis magna quis vulputate. Cras aliquet convallis efficitur. &lt;/pre&gt; &lt;pre id="visible"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent bibendum lorem felis, sit amet sodales nunc gravida eget. Integer mollis quis magna quis vulputate. Cras aliquet convallis efficitur. &lt;/pre&gt;</code></pre> </div> </div> </p> <p>The <a href="https://www.w3.org/TR/css3-box/#overflow-x" rel="noreferrer">W3C spec</a> says:</p> <blockquote> <p>The computed values of ‘overflow-x’ and ‘overflow-y’ are the same as their specified values, except that some combinations with ‘visible’ are not possible: if one is specified as ‘visible’ and the other is ‘scroll’ or ‘auto’, then ‘visible’ is set to ‘auto’.</p> </blockquote> <p>But this makes no mention of the case when <code>overflow-x</code> or <code>overflow-y</code> is set to <code>hidden</code>, which to me implies that this combination is indeed meant to be possible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload