[CSS] Need help with positioning.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
xitura
Forum Newbie
Posts: 20
Joined: Fri Sep 07, 2007 11:25 am

[CSS] Need help with positioning.

Post 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.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Have you tried Margins? Or Padding?

Code: Select all

margin-top:-2px;

Code: Select all

padding-top:-2px;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post 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.
xitura
Forum Newbie
Posts: 20
Joined: Fri Sep 07, 2007 11:25 am

Post 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.
Post Reply