tags:

views:

264

answers:

5

Hi. I have a header, mainbody and footer. Header and mainbody are properly styled. Now for footer I want to make it appear behind mainbody, so I used:

z-index: -1;
position: relative;
top: -60px;

This gives the desired result, but I get an extra space of 60px at the bottom.

How do I clear this extra space?

+1  A: 

One way to achieve that would be to put the div inside another, absolute'ly positioned div so that it's taken out of the document flow.

Raveren
I'm also not sure what you achieve with `z-index`, I'm pretty sure, nothing would change if you'd turn off that rule. IIRC, negative `z-index`'es hide content when printing - and that's it.
Raveren
Actually with Z-index = -1, I want the footer to half appear behind body. So it looks as if my footer starts from somewhere behind the body and continues till the end of the page.
noobcode
I *think* z-index only works with positive values except the printing case. Anyway, did you try the `absolute` solution?
Raveren
I used Z-index = -1 , and it takes my div at the back of the main body div. Just exactly how i wanted. On to trying the absolute solution.
noobcode
+2  A: 

The “extra” space at the bottom is the space that the footer would be taking up. Relatively positioned elements still take up the same space in the page’s layout flow, even though they’re appearing somewhere else.

You could try a negative bottom margin on your mainbody. You may find this means you don’t need top: -60px; on your footer.

Paul D. Waite
I tried that, but it got the main body down. The extra space due to footer still exist. Thanks for your reply..
noobcode
Hmmm. How about replacing `top: -60px` on the footer with `margin-top: -60px`? That should affect the document flow and the footer’s positioning. (I’m assuming your footer is 60 pixels tall.)
Paul D. Waite
+1  A: 

Paul is correct. margin-top: -60px; instead of top: -60px;. Another possible solution would be to set the "mainbody" to position: relative; then to use position: absolute; bottom: 60px; on the footer - although this woild mean the footer needs to be moved inside "mainbody". though as long as the parent of footer flows with "mainbody" you could use this same trick on that element instead.

prodigitalson
Thanks prodigitalson. Tried both the solutions you provided. For margin-top : - 60px it does not make any changes and remains there itself. However in DW it shows the effect. Also using position :absolute causes the div#footer to behave differently. I think there is something in the mainbody itself that is causing the error. Thanks all for quick help tips and pointers. Really appreciate.
noobcode
+1  A: 

Not really a direct answer to your question, but depending on what you want to display behind the main content, you can perhaps just fake it.

If it´s an image, you can simply put it in html {} or body {} (or a div that encapsulates all content) and align it to the bottom.

jeroen
Thanks jeroen for you reply..
noobcode
A: 

Hi guys, the margin-top : -60px worked. I had issues with mainbody. It was not properly coded. Thank you all for such a quick reply and helping me out at the same..Thanks

noobcode
Hi :) In the future, please post comments as **comments** by clicking `add comment` link. Do not post comments as **answers**, they will get lost in noise. If you find an answer useful, press the up arrow on the left hand side of the answer. If you find an answer blatant or nonsensicial, press the down arrow. Leave the remnant of answers neutral. If an answer *actually* helped in solving the problem, mark it **accepted** by clicking the white checkmark on the left hand side. Also see http://stackoverflow.com/faq
BalusC
OK, Got it..next tym will take care of it.
noobcode