I am probably overlooking something obvious. I would have thought that I could add some space between the two top elements ( the h1 and teh form) AND .slogan element (DIV) that follows by merely adding margin-top: ( and clear:both; for good measure).
This works fine in FF, but gets ignored in Safari. Oddly enough if REMOVE the two top elements all together the margin is there! Also, if I add MARGIN-BOTTOM to either floated element then I get the space I wanted; it seems odd that there would be an effect of a previous element’s bottom margin, but the element cant employ a margin-top to do the same thing.
At this point I thought I may have forgotten to close a tag somewhere but, the markup validates…
I think I am over-tired and making a stupid error somewhere… a fresh set of eyes and a wise opinion would be greatly appreciated.
It seems that Firefox is treating the display:table (on slogan) as a block formatting context and thus not collapsing the margins.
Display:table on its own doesn’t create a block formatting context so it seems Firefox may be confused as it generates an anonymous display:table-cell which does create block formatting context.
If you change the display:table to inline-block instead (or float) then other browers will observe the margin as inline-block creates a new block formatting context.
Looks like a bug or perhaps a different interpretation of the specs.
As mallory suggested above I always apply a bottom margin to floats to be sure that the margin is applied as some browsers treat clearance differently also where margins are concerned.
I was going full DS60… and am endeavoring NOT to wrap the two elements if I can achieve the effect w/o it.
#lgn {float:right; }/* i can get teh desired effect by adding margin-bottom:20px here */
Anyway, somewhere Paul O’B has an article showing how sometimes a top-margin can slide up under Joe Float. While I’m surprised that the one acting different is Safari (prolly also Chrome then too) and not IE, that they use different rules to deal with floats and top margins doesn’t make my eyespoplikeamosquito
Yeah it wasn’t something that I was expecting… which is why i wanted to know if it was me… or some bizzare bug…
It does work when I put margin bottom on the form , instead of div.slogan, I dont know which of the two elements will be the tallest, so it seemed more logical to push with margin top, taht way i would know its THAT specific distance…
If both floats have 3em bottom margin for example, then whoever is lower will still give you 3em between them (whoever they are) and the slogan. If you always want 3em between slogan and whoever is lower.
Would suck though if the screen is allowed to shrink and then one float could sit above another, since you may not want 3em between them if they stack. If that’s the case, the quick and dirty is to wrap the floats in a box and let the box have the bottom margin.
Anyway, somewhere Paul O’B has an article showing how sometimes a top-margin can slide up under Joe Float. While I’m surprised that the one acting different is Safari (prolly also Chrome then too) and not IE, that they use different rules to deal with floats and top margins doesn’t make my eyespoplikeamosquito
Margin-tops like to slide up behind people and whack them in the back of the head with a stick. Clearing doesn’t stop this.
…Have you tried swapping to bottom margins? Those are less devious.
As a general rule I’d rather push down than push up. Padding-top on the body instead of margin-top on the body’s first kids, and margin-bottom on the h1 and form to push away the slogan.
Stomme!
I thought I was pushing down. This was my SLEEPY thought process.
The H1 + FORM are floated ( left and right, respectively) at the top of the page, div.slogan clears both and is then pushed down by its margin top.
It does work when I put margin bottom on the form , instead of div.slogan, I dont know which of the two elements will be the tallest, so it seemed more logical to push with margin top, taht way i would know its THAT specific distance…