define margin using pixels or percent?
Hi there! This is my question.
Let's say I have two divs, div1 and div2. To define the top margin of div2 respect div1, I can do it in two ways using css.
What's the best way to do it?? I am sorry because I know this is a stupid question, but I want to know the main differences between those two ways.
Thanks a lot!
It totally depends on if you want the top margin to always be 20px or if you want it to be 20% of the screen or containing div size.
To throw something else into the mix, you could also use ems (based on your 20px, that would be 1.25ems).
So basically do you want your top margin to be fixed or fluid / responsive (either way, use margin-top, not just top as that is for use with position: relative or position: absolute).
Yup as simple as simplypixie said!
I prefer Pixels more....and em is better then %.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)