I have this issue where a space is appearing between two divs and I don't know what is causing this. Basically it is just one div with three smaller divs of fixed height inside of it. The space is between the block-title
and block-content
divs. There is no space between the block-content
and block-footer
Here is the HTML:
<div class="block buy">
<div class="block-title">
<span class="line-1">Title</span>
</div>
<div class="block-content">
<h2></h2>
</div>
<div class="block-footer">
</div>
</div>
And here is the CSS:
.block {
width: 300px;
margin-left: auto;
margin-right: 15px;
display: inline-block;
vertical-align: top;
margin-top: 35px;
font-weight: 400;
text-align: left;
}
.block-title {
height: 70px;
padding: 20px;
}
.block-content {
width: 100%;
height: 255px;
text-align: center;
}
.block-footer {
height: 75px;
}
.block-title,
.block-content,
.block-footer {
color: #fff;
}
.line-1 {
font-weight: 300;
font-size: 20px;
display: block;
}
.buy > * {
background-color: #558F38;
}
A live JSfiddle is here: JSFiddle
Any ideas why this is happening?
Edit
So the reason why the space appears is because the <h2>
elements margin goes outside of the containing div. Why is it not contained inside the div?