Body height 100% displaying vertical scrollbar

后端 未结 13 2126
予麋鹿
予麋鹿 2020-12-07 21:48

Out of curiosity, considering the example below, why does having the margin on the #container div cause a vertical scrollbar to appear in the browser? The container is much

相关标签:
13条回答
  • 2020-12-07 22:36

    I saw this problem fixed before where you put all the contents of body in a div called wrap. Wrap's style should be set to position: relative; min-height: 100%;. To position #container div 50px from the top and left put a div inside wrap with a padding set to 50px. Margins will not work with wrap and the div we just made, but they will work in #container and everything inside it.

    here's my fix on jsfiddle.

    0 讨论(0)
提交回复
热议问题