Apply the property box-sizing: border-box; to all of your elements (selector *) so the extra space caused by borders, padding, and margins is then included in the 100% and not added to the 100% (i.e. 100% + 5px border).
Try to use 100vh in place of 100% for height and also set box-sizing:border-box; for all elements, I have made some changes to the css, please check if it works
Add this line on top of your css, that should prevent scrolling
* {
box-sizing: border-box;
}
Problem :
This question is everywhere and the solution is always the same but it never works for me and I have no idea why! I simply need my div to fill the entire view port without creating a scroll bar. Who knew this would be so difficult. Everyone says to just set body and html margins to zero but this doesn’t work. I still have a vertical scroll bar! I’m getting really frustrated and I would really appreciate some help. Here is the JSFiddle https://jsfiddle.net/davdarobis/d3k4hv6q/23/.
I can’t use the top: 0bottom: 0 solution because this seems to screw up the height: 100% property of its children. I’m completely stuck. Any ideas? Thanks.
Comments
Comment posted by T Tse
It’s probably the border.
Comment posted by Soban
Try height 100vh. This tells that the height will be 100 view height of the screen.
Comment posted by Ramon de Vries
why would you want the body on absolute anyway?
Comment posted by Soban
@ShioT I think the same
Comment posted by box-sizing
It’s the border.. to solve read this
Comment posted by Dallin Davis
Oh wow I always thought borders were drawn around the inside of the container not the outside. This helps a lot! Thank you so much!