Position:absolute causes horizontal scrollbar

前端 未结 4 1979
你的背包
你的背包 2020-12-29 02:44

Absolutely positioned (side yellow advertisements) div\'s cause unwanted horizontal scrollbar when window is resized (size decreased) beyond them. Scrollbar should appear on

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 02:52

    Absolutely-positioned elements that expand beyond the boundaries of the body seem to cause scrollbars to appear, for some reason. You can remedy this by simply wrapping everything inside the body tag in a relatively-positioned div styled with overflow: hidden;. The absolutely positioned content that expands beyond the boundaries of this container won't cause scrollbars on the window.

    Here's a working example: http://jsfiddle.net/8UkQA/1/

提交回复
热议问题