margin-bottom property of a div's last element doesn't "extend" the div

Posted by kitsched on Stack Overflow See other posts from Stack Overflow or by kitsched
Published on 2010-05-12T10:30:28Z Indexed on 2010/05/12 10:34 UTC
Read the original article Hit count: 217

Filed under:
|
|

I have an element in a div, which has a background image. Below the div I have another div with another background image. Now the problem is that if the last element contained in the first div has margin-bottom applied there will be a gap between the 2 divs like this:

Screenshot

Notice the gray gap caused by the margin-bottom property of the h2 element contained within the first div. I know this can be solved if I switch margin-bottom to padding-bottom but what if I need margin-bottom?

How to fix this?

© Stack Overflow or respective owner

Related posts about css

Related posts about html