I have a html and css code that make a weird spacing happen between 2 divs and between other divs there is no spacing, for no obvious reason (at least to me) And because of that problem my first 2 divs can't fit in same row. And I have second code with simuilar code that doesn't have any spacings between divs, can anyone find a reason for this kind of thing to happen, what am I missing?
1st code:
html,
body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
.col-4 {
width: 33.333%;
}
.form-group {
display: inline-block;
padding: 8px;
background: yellow;
margin-top: 24px;
vertical-align: top;
}
<body>
<div class="form-group col-4">1</div>
<div class="form-group col-4">2</div>
<div class="form-group col-4">3</div>
<div class="form-group col-4">4</div>
<div class="form-group col-4">5</div>
</body>
2nd code:
div {
width: 33.333%;
height: 30px;
vertical-align: top;
}
#div1 {
background-color: red
}
#div2 {
background-color: orange
}
#div3 {
background-color: yellow
}
#div4 {
background-color: green
}
#div5 {
background-color: blue
}
#div2,
#div3,
#div4 {
display: inline-block;
}
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
<div id="div5"></div>