How to always leave 20px margin at the bottom of the page?

Asked

Viewed 88 times

2

I have the CSS on body:

margin-bottom: 20px;

But always Uga, for example, if I use position: absolute; he loses that margin of 20px. How to do it in other ways?

  • 3

    Could you define "Uga"? What happens most exactly?

  • if I use position: Absolute; it loses that margin of 20px...

  • I suggest you better understand how the position: absolute;. If you have something absolute inside, for the body CSS it’s like there isn’t. That’s how it works. You need to understand this to know how to handle your specific case.

  • Is it possible to create a jsFiddle that reproduces your problem? if we’re not going to be guessing what your problem might be...

3 answers

3

If the problem is with position absolute, use a bottom: 20px. On the other hand margin-bottom in body resolves.

  • example ???????????

  • @user3230262 I think this is too simple to require an example. Have faith and use the dsantoro solution ;)

  • body { bottom 20px; }

  • that doesn’t work...

2

For absolute values, use the property bottom only.

Use:

.divTeste { position:absolute; bottom:20px; }

HTML:

<div class="divTeste"></div>

0

Checks by inspecting elements, if your body is 100% at the height of the page, if the margin-botom:20px is to work or also position:Absolute; bottom:20px;

Now if in inspect elements of your body is not 100% is why there is something wrong there on your page.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.