Page 1 of 1

Div elements pushed down

Posted: Mon Jun 01, 2009 8:59 am
by Sindarin

Code: Select all

<div>
<div style="position:relative;left:0px;top:0px;width:32px;background:red;">test</div><div style="position:relative;left:55px;top:0px;width:32px;">test</div>
</div>
It should be displaying as

Code: Select all

[b]test test[/b]
not

Code: Select all

[b]test
      test[/b]
I tried every possible combination with my external stylesheets unlinked as well. What's going on?

Re: Div elements pushed down

Posted: Mon Jun 01, 2009 11:41 am
by kaszu
Setting top, left, right, bottom for 'relative' position element doesn't puts it at the top, left, right or bottom, but it acts similar to margin. You should use floats or set position to absolute.

Re: Div elements pushed down

Posted: Mon Jun 01, 2009 1:02 pm
by iFlex
kaszu wrote:Setting top, left, right, bottom for 'relative' position element doesn't puts it at the top, left, right or bottom, but it acts similar to margin. You should use floats or set position to absolute.
:mrgreen: I was just about to mention position absoute! 8)

Re: Div elements pushed down

Posted: Mon Jun 01, 2009 2:09 pm
by pickle
You could try floating the first div too.

Re: Div elements pushed down

Posted: Wed Jun 17, 2009 9:31 am
by ofir0803
or u can do this...

Code: Select all

<div style="width:64px;">
    <div style="float:right;width:32px;background:red;">test</div>
    <div style="float:left;width:32px;">test</div>
   </div>

Re: Div elements pushed down

Posted: Thu Jun 18, 2009 4:10 am
by Sindarin
Thanks it worked now.