x: hidden adds a vertical scrollbar

This question already has an answer here:

  • CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue 5 answers

  • Check out this answer to a related question: https://stackoverflow.com/a/6433475/3583023

    It explains why

    el {
      overflow-x: hidden;
      overflow-y: visible;
    }
    

    renders as

    el {
      overflow-x: hidden;
      overflow-y: auto;
    }
    

    which usually renders the same as

    el {
      overflow-x: hidden;
      overflow-y: scroll;
    }
    

    because the auto value of overflow-y is scroll in most browsers.

    So, in order to achieve this effect, we can't use the overflow-x/overflow-y properties. I've experimented with the clip property as a potential alternative, but no luck so far: http://jsfiddle.net/qvEq5/


    Firstly, this fiddle shows the problem which you describe.

    As yet, I don't know how to get around this, but it seems like the spec hints to this here:

    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'.


    Just an hour ago I had the similar problem except the problem occurred when I had specified overflow 's value as auto . I didn't use overflow-x or overflow-y , I just needed it to fully contain my two lists that were floating on opposite ends.

    What worked for me was that I changed overflow 's value to hidden . Try that. I had set the max-width to 100% and instead of specifying height, I just used overflow: hidden .

    Hope that helps.

    链接地址: http://www.djcxy.com/p/87822.html

    上一篇: 溢出隐藏不似乎在Firefox中工作

    下一篇: x:隐藏增加了一个垂直滚动条