I see whitespace between the div's border and the nav in chrome only at a specific screen size. I also see it in the fiddle so I don't have any extra code. Also same happens in the snippet, I see the white space only when I expand it to full page.
*{
padding: 0;
margin: 0;
font-size: 0;
line-height: 0;
}
div{
min-height: 100vh;
border: 0.5vw solid red;
width: 100%;
box-sizing: border-box;
}
nav{
background: black;
height: 11vh;
}
<div>
<nav>
</nav>
</div>
The Architecture: The content is surrounded by the border, the space between the content and the border is called the padding, while the space between the border and the other elements in the document is called the margin.
You can achieve this by removing the margin from the H2 element using css. If you only want to remove the space from the top or bottom of the <h2> element you can use the margin-top and margin-bottom CSS properties.
You get whitespace there because you have whitespace inbetween the divs. Whitespace between inline elements is interpreted as a space. However, this is a bad way to do what you want to do. You should float the elements if thats what you want to do.
Line Height Property: The CSS line-height-property can be used to set the height of the line, whose value is set to normal, by default. By setting the height of the container at 0%, the white space can be removed.
The problem is this:
border: 0.5vw solid red;
and that doesn't give you a whole number as such it anti-alias the border with the white DIV and what you are likely be seeing is more orange than white.
I've come up with a hack by having 2 separate divs one for the nav and that div background is black so your border is anti-alias to black rather than white.
Fiddle: http://jsfiddle.net/dg45wfc8/
*{
padding: 0;
margin: 0;
font-size: 0;
line-height: 0;
}
.content-div {
min-height: calc(((100vh - 11vh) - 0.5vw));
border: 0.5vw solid red;
width: 100%;
box-sizing: border-box;
border-width: 0 0.5vw 0.5vw 0.5vw;
border-style: solid;
border-color: red;
}
nav{
background: black;
height: 11vh;
}
.nav-div {
border-width: 0.5vw 0.5vw 0 0.5vw;
border-style: solid;
border-color: red;
background: black;
}
<div class="nav-div">
<nav>
</nav>
</div>
<div class="content-div">>
</div>
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