I have this markup:
<div class="myToggledDiv">
<div>content</div>
</div>
<div style="margin-top: 10px;">
content
</div>
Via jQuery, I'm doing a .slideToggle to show/hide the top div.
I'd like there to be the 10px space between the two divs at all times, whether collapsed or expanded.
The behavior, however is that as the top div slides down, the 10px margin remains but as soon as the top div is finished sliding down the 10px margin disappears. It appears to be a margin collapse issue perhaps.
The solution I came up with is this:
<div class="myToggledDiv">
<div>content</div>
</div>
<div style="font-size: 1px"> </div>
<div style="margin-top: 10px;">
content
</div>
The is the key as there needs to be content in the div to 'separate' the two and retain the 10px of margin.
I tried the .clearfix:after approach as well, but that doesn't work in this scenario, so perhaps this is a jQuery centric issue. Has anyone ran into this and found a more elegant solution than the extra div?