When I use overflow: hidden
, top and bottom margins appear around these containers. I really don't understand why this should be. I'm looking for an explanation to help me understand CSS better.
Here is the code:
CSS CODE:
#container {
border: 2px solid black;
overflow: auto;
}
.field {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
display: inline-block;
padding: 0 5px;
border: 5px solid #FC0;
line-height: 1.5em;
overflow: hidden;
}
.w50 {
width: 50%;
}
.w100 {
width: 100%;
}
HTML CODE:
<div class="w50" id="container">
<div class="field w50">
<input type="text" size="100" value="input field that overflows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">
</div>
<div class="field w50">content</div>
<div class="field w100">content</div>
</div>
If I don't use overflow: hidden
, the container has no top and bottom margins, but I do have overflow issues.
If I use overflow: hidden
, the container (apparently) has top and bottom margins, but my overflow issues go away.
Is there a way to use overflow: hidden and avoid this extra white space?