简体   繁体   中英

Height:100% and Margin problems, extending past 100%

Here is my playground link: 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. 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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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