简体   繁体   English

高度:100%和保证金问题,超过100%

[英]Height:100% and Margin problems, extending past 100%

Here is my playground link: http://cssdeck.com/labs/7u6ex40p 这是我的游乐场链接: http : //cssdeck.com/labs/7u6ex40p

As you can see, i've given it a height of 100% yet it extends further than 100% with the margins. 如您所见,我给了它100%的高度,但它的边距超出了100%。 Evidently this is because of the margins, I've tried changing them so the margin is 2% and the height is 96% yet this didn't work. 显然这是由于页边距,我已经尝试过更改它们,以使页边距为2%,高度为96%,但这没有用。 Im at all ends here. 我在这里到处都是。

Cheers, Chris 克里斯,干杯

Instead of having a margin for the pageborder, make it padding for the body and set box-sizing to border-box. 不必为页面边框留出边距,而应为正文进行填充,然后将框大小设置为border-box。

html, body {
  height:98%;
  width:100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  background-color:#fff;
  margin:0;
  border: 0;
  padding: 2%;  /* changed */
  box-sizing: border-box;  /* changed */
}

#pageborder {
  background:  rgba(86, 86, 86, 0.06);
  height:100%%;
}

http://cssdeck.com/labs/vla26uvc http://cssdeck.com/labs/vla26uvc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM