View Full Version : Positioning Divs?


theANWSER
06-19-2004, 05:22 AM
I need help with positioning divs.

i know that this is the code:
<div style="position:absolute; top:#; left:#; width:#;">
but i dont understand what i should replace the # with

someone plaese help
thanks

Owlie42
06-19-2004, 05:27 AM
the #s should be replaced with pixel values. For example:

*is stealing her own code*

<div style="position: absolute; left: 320px; top:10px;">
<img src="blah.jpg"></a>
</div>

'blah.jpg" will be positioned 320 pixels from the left edge of the page, and tex pixels from the top (top left corner would be left: 0px; top: 10px;)

:buckt:

pb&j
06-19-2004, 05:28 AM
# is replaced with a number of pixels.

example...

<div style="position:absolute; top:100px; left:200px; width:50px;">
some text here
</div>

the div will appear 100 pixels from the top,
200 pixels from the left,
and will be 50 pixels in width.

theANWSER
06-19-2004, 05:29 AM
ok but how do i find out how far it should be from the top, etc.? do i do trial and error or is there a better method?

pb&j
06-19-2004, 05:32 AM
trial and error.
usually does not take much time.

theANWSER
06-19-2004, 05:33 AM
great thanks a lot :)

Dude128
06-19-2004, 05:34 AM
if you have a specific spot in your layout or something, try taking a screen shot, and using a graphics program to get the locations. even in Paint if you move the cursor around it will show you the position in the status bar, on the lower right. just be sure to find the difference between the spot you want and the edge of the actual page, because the former has the edge of the window and any toolbars and stuff on the left and top... if that made any sense whatsoever :P