views:

27

answers:

2

Hi, I have a problem I have been trying to solve, but without any progress.

This is a summary of my code:

<div id="container">
     <div id ="content">
          Some content here (Varying height)
     </div>
</div>

body {
     background-image: url('img/bg_Body.gif');
     margin:0px 0px 0px 0px;
}

#container {
    position: relative;
    width: 880px;
    margin-left: auto;
    margin-right: auto;
    top: 0px;
    min-height: 100%;
}

#content {
    position: absolute;
    top: 0px;
    left: 0px;
    background-image: url('img/faux_tile.png');
    min-height: 200px;
    padding-top: 105px;
    padding-right: 80px;
    min-width: 400px;
    padding-left: 80px;
    padding-bottom: 110px;
}

How do I add a margin between the content and the end of the page? The faux_tile.png covers to the end of the page, I want a margin between the end of the page and the faux_tile.png, which is a small margin showing bg_Body.gif.

Please help me, it is greatly appreciated. Thanks!

A: 

You could give body a margin-bottom.

That should force a margin even though your container is position: absolute.

Pekka
Hi, thanks for your suggestion. The margin-bottom does not seem to work, as if I put margin-bottom: 900px; , it shows a margin around 100px, but when the content height increases, the margin decreases. I will need a fixed margin height regardless of the length of content.
initialsHL
@initialsHL ah, okay. Well, the reason why this is a problem is the `position: absolute`. Why do you need that in the first place? I can't really see the benefit in the scenario you present - is there more to it?
Pekka
No I didn't specifically put position: absolute, it's just that Microsoft Expression Web 4 puts it as default when I added the <div>. Can you help me edit my file so that there will be a margin at the bottom showing the background image, regardless of the content's length? Here's my file: mediafire.com/?lmnsfa1vinkc1q5 Thank you very much!
initialsHL
@initials if you remove `position: absolute` giving the body a `margin-bottom` will work.
Pekka
A: 

try this:

#content {
    position: absolute;
    top: 0px;
    left: 0px;
    right:0;
    bottom:20px; /*this should give you 20px margin at the bottom*/
    background-image: url('img/faux_tile.png');
    min-height: 200px;
    padding-top: 105px;
    padding-right: 80px;
    min-width: 400px;
    padding-left: 80px;
    padding-bottom: 110px;
}

the other way could be to give #container a min-height of less than 100%

Moin Zaman
Hi, thanks for your suggestions, but both did not work for me. For the first, it caused the padding-bottom to increase or decreased the content's height. And no matter what value I put for #container min-height, it stays the same height, even if its like 500% height.
initialsHL
how about the same as above, but remove the `padding-bottom`
Moin Zaman
It showed a margin at the bottom, but decreased the #content height and some texts went out of #content.
initialsHL
ok, that's a good start. your total height will be `min-height` + `padding-bottom` + `padding-top` so if you add 20px in the bottom via `bottom:20px` then remove 20px from `min-height`
Moin Zaman
Hi, thanks but it still did not work. Can you help me edit my style.css to create a margin at the bottom? My files are here: http://www.mediafire.com/?lmnsfa1vinkc1q5 I need the margin to show the background image. Many thanks!
initialsHL