Vertical Scrollbar leads to horizontal scrollbar

后端 未结 5 1229
遇见更好的自我
遇见更好的自我 2020-12-15 03:12

My CSS looks like this:

div.SOMECLASS {
  position: absolute;
  max-height: 300px
  height: auto;
  width: auto;
  overflow: auto;
  ...
}

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 03:43

    I found a solution which is working but far from perfect:

    I added a padding-right : 15px to my div, to automatically grow the entire div. Now if the vertical scrollbars appear, they fit within the padding so the horizontal width is still ok.

    Regretfully the padding of course also shows up when no vertical scrolling is needed, making my div just a tiny bit wider than it would have to be... :/ Well, in my eyes this is still preferable to unneeded horizontal scrollbars.

提交回复
热议问题