Can I expand a div so the overflow-y:auto scrollbar doesn't clip the div content?

后端 未结 2 706
春和景丽
春和景丽 2021-01-19 01:14

Similar question, without a great answer:
How can I include the width of "overflow: auto;" scrollbars in a dynamically sized

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 01:53

    First: To remove the horizontal scrollbar set overflow-x: hidden; as Trent Stewart has already mentioned in another answer.

    CSS Approach:

    One thing I have done in the past is to add a wider wrapping div around the content div to make room for the scrollbar. This, however, only works if your container width is fixed... and may need to be adjusted (by serving different styles) in various browsers due to variable rendering of scrollbars.

    Here a jsfiddle for your case. Note the new wrapper

提交回复
热议问题