I’m making a section with a height of 100vh, but I don’t know why I’m getting extra white space or more than 100vh height due to which its adding scroll bar and white space.
Here is my HTML code :
#second {
color: #fff;
padding-right: 10vw;
padding-top: 200px;
background-color: black;
width: 100%;
height: 100vh;
}
.elem {
width: 100%;
padding: 3.5vw 3vw;
border-top: 1px solid #888;
}
.elem h1 {
text-transform: uppercase;
font-size: 7.6vw;
opacity: 0.7;
}
.elemlast {
border-bottom: 1px solid #888;
}
<div id="second">
<div class="elem">
<h1>The Plug</h1>
</div>
<div class="elem">
<h1>ixperience</h1>
</div>
<div class="elem">
<h1>hudu</h1>
</div>
</div>
Can you guys please take a look and tell me what am I doing wrong.
Excuse my English.
3
Answers
Your English is fine! From the looks of it, there might be a few factors causing the extra whitespace. Firstly I would add box-sizing which ensures that any padding or border would be included within the width / height of the element:
If this doesn’t work, try resetting the default margins and seeing if this helps:
And finally, if these both don’t solve it, reconsider padding on the
100vh
section, decrease the value and see if that worksI always get used to this when starting any HTML/CSS projects.
Reset all the margin and padding and also set
box-sizing: border-box
so that border and padding are included to the total height of the containers. And finally, for the#second
id set a responsive height value so that it doesn’t force the content to overflow.