Page 1 of 1

[CSS] Need help with positioning.

Posted: Wed Sep 12, 2007 5:41 pm
by xitura
I need to get a div to move up a few pixels. I've played around with both absolute and relative position but I can't get it right. Relative position messes up the table below the div. I also tried to add:

Code: Select all

top: -2px;
But that didn't work either.
The css for the div is:

Code: Select all

#hidden_div {
	visibility: hidden;
	width: 91px; 
	height: 30px;
	position: absolute;
	background: url("images/pic01.jpg");
}
The content above and below is dynamic so I can't set the top to it's real value in pixels from the beginning.

I am really tired right now and perhaps my explanation isn't the best, feel free to ask if there are any questions.
Thanks.

Posted: Wed Sep 12, 2007 5:51 pm
by Zoxive
Have you tried Margins? Or Padding?

Code: Select all

margin-top:-2px;

Code: Select all

padding-top:-2px;

Posted: Wed Sep 12, 2007 5:51 pm
by feyd
There may be other bits in your code that is shifting the div by that small amount. Otherwise I would suggest potentially rethinking the design if it must be that pixel precise.

Posted: Thu Sep 13, 2007 1:03 am
by matthijs
You could use a negative margin (as Zoxive suggested) or relative positioning.

Code: Select all

margin-top:-2px;
or
position:relative;
top:-2px;
Which one to choose will depend on the rest of the page.

Absolute positioning will take the element out of the flow and is therefore not useful for a relative displacement.

Posted: Thu Sep 13, 2007 10:37 am
by xitura
Thank you all,

Code: Select all

margin-top
did the trick.
@feyd: Yeah, I'm thinking about rebuilding the design completely. I just don't have the time or the skills for this right now.