views:

32

answers:

3

Hi All, I am trying to get on this page (http://musicaladvocacy.org/) the area where it says "Home" (The White Container in the grey gradient) to go ~60 px up, but as you can see it does that as well as moves the parent container up. I just want the white box to move up NOT the whole thing. So it should look like this: http://musicaladvocacy.org/index-margin.jpg

Thanks for any ideas!

+4  A: 

You can apply position:relative; top:-60px; on the element you need to shift up.

#el {
   position:relative;
   top:-60px;
   z-index: 5;
}
meder
+1 Actually... I think that pretty much is ideal. Negative margins don't break the flow of the page, so trying to use them will always push other elements around. This sort of layout scenario is exactly what relative positioning is good for.
derekerdmann
You Rock! Thanks!
Nitroware
A: 

What you are searching for is the css properties "position" and "top".

#div-1 {
  position:relative;
  top:-60px;
}

See step 2 on this guide. Many other websites have more information about this properties too.

Raffael Luthiger
+2  A: 

You could also add 1px padding to the top of the parent, and continue using negative margins.

.width { padding-top: 1px; }
.content { margin-top: -60px; }

This works because margins that are immediately up against one another combine into a single margin.

Ryan Kinal
+1 I haven't seen that used before. Nice!
derekerdmann
How does the top padding make the margins collapse, again?
meder
If the padding is 0, then the margins are immediately adjacent. Immediately adjacent margins collapse. If the padding is at least 1px, then the parent margin and the child margin are separated, and they don't collapse.
Ryan Kinal