Unstoppable Domains

CSS - Confused.. looking for answers

Spaceship Spaceship
Watch

JYM

Established Member
Impact
64
Hi

What's the difference between margin-top and top?

I know margin-top can be used whenever whereas top can only be used if the element is absolutely positioned... but which is more commonly used and why?

Also would you recommend using relative positioning for my entire webpage? I will not have anything overlapping but I think if I position everything relatively I can add a footer to the bottom of the page. Pros/cons?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Which one is more commonly used doesn't matter.. it's which one you need to use.

Using margin's is better unless you are going to absolute position everything on your layout (or at least a few..)

If you use relative positioning for the whole page, adding a footer to the bottom will be hard as you have to add it below everything and the height could change.
 
0
•••
Actually I just figured out a very simple way of adding a footer.

create a div for header
create a div for everything between header and footer (call it container)
create a div for footer

Make the above three relatively positioned.. then everything inside can be absolutely positioned :)
 
0
•••
.. You don't know what you're talking about. >_<

Using absolutely positioned elements inside relatively positioned elements means the relative ones are useless. Normally, you put the header and footer INSIDE the container.
 
0
•••
well yeah but then I also found people having many problems with the footer...

the way I talked about actually does work... but only if all the content stuff in the middle is relative too.

Actually the regular way probably works too... I am probably doing it a really stupid way but I had to look at my code from a different point of view..
 
0
•••
If you put an ABSOLUTE positioned element in ANYTHING, it will go where you have the top and left (and right and bottom) even if it is not inside of the outside element.

well yeah but then I also found people having many problems with the footer...

Yes, because YOU CAN'T DO IT THAT WAY!

Actually the regular way probably works too... I am probably doing it a really stupid way but I had to look at my code from a different point of view..

The 'regular way' does not exist. You are doing it in a stupid way, because that's not how CSS works. Look up how to position elements.. Never have I heard/seen someone say they need to look at CSS from a different point of view. (Other than when trying to do something not done before..)

Again, you don't know what you are saying!
 
0
•••
I know that absolute positioning puts things according to the top left of the page... however when I did a google search on footer it said you could make a footer by giving it absolute value positioning inside a relatively positioned element. I have discovered that if I made the box containing my main text relative, the footer would always be under it with this code:
Code:
bottom: 0px;
. I'm probably just bad at describing what I do but so far it is working just the way I want it.. perhaps I did something unnecessary but it is working out...
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back