beennn Posted June 22, 2013 Share Posted June 22, 2013 (edited) My understanding is, collapsing margins on a floating div is not possible, is there a work around which can achieve the same effect? Edited June 22, 2013 by beennn Link to comment Share on other sites More sharing options...
niche Posted June 22, 2013 Share Posted June 22, 2013 What's your situation? Link to comment Share on other sites More sharing options...
dsonesuk Posted June 22, 2013 Share Posted June 22, 2013 Apply margin size of child element to parent is good work around. Link to comment Share on other sites More sharing options...
beennn Posted June 22, 2013 Author Share Posted June 22, 2013 I have several of the same floating div, and I'd like them to have an equal margin between themselves and other elements on the page, for example the header and footer (if there's a margin of 5px on the floating div, this stacks to 10px when touching the same div, however when hitting the header or footer, is only 5px). Is it in anyway possible to collapse a margin connected to a floating div? Currently I've just added and extra margin to the top and bottom of the footer/header to make the difference, but in the long run, if it's possible; it would be easier if there was a way to collapse them. Link to comment Share on other sites More sharing options...
dsonesuk Posted June 23, 2013 Share Posted June 23, 2013 What you preset all div with set margin clear: both; and overflow: hidden div { background-color: #9999CC; clear: both; margin: 0 0 10px; overflow: hidden;} it would just mean the last div margin zeroed. or you may want to try :last-child Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now