I want to create a one-scroll-page, like each section is full height from screen.
But when I use 100vh, it doesn't take whole screen height, but more like 95%.
Sure! Applying min-height: 100vh to the body element should do the trick. Here, 100vh means that the initial body height will take 100% of the viewport height, whereas the use of min-height instead of height will let the body element grow even more if necessary.
Yes, 100vh is 100% of a viewport height (your device), when pure 100% only fill all available parent area (parent block can have e.g. 50px height and it will fill only to this parent height).
Min height 100vh means the element should occupy the web browser viewport height. This is always 100 percent of the web browser's viewport height. If there is more content, the element will stretch more than the viewport's height, which is a code example that will clear things up.
position:absolute You can also use position absolute as well as set all the viewport sides (top, right, bottom, left) to 0px will make the div take the full screen.
Adding the code below to your CSS should fix it:
html,body{
margin:0;
}
This is caused by the default margin being 8px
so redefining it using CSS will correct it.
Illustration with margin Set:
#Orange{
height:100vh;
width:100vw;
background:orange;
}
body{
margin:0;
padding:0;
}
<div id="Orange"></div>
Without the margin:0
adjustment:
#Orange{
height:100vh;
width:100vw;
background:orange;
}
body{
padding:0;
}
<div id="Orange"></div>
Adding this code should adjust the margins for your container.
.container-fluid{
margin-top: 0;
margin-bottom: 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With