Jump to content

Collapsing Margins on Floating Divs


beennn

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...