My stackoverflow answer #7

by krike in Other / Stackoverflow answers on 15 Nov 2010

Each week I feature one of my answers on stackoverflow hoping it might help other people.

The question

This weeks question by Junaid Abe Miessler: Is it possible to have auto margins when you have position:absolute?

I’m having an issue where a div is not butting up to the very top of the page. I tried to solve this by adding


which put it at the top like I wanted but it also went to the left of the page. I want it to be centered in the page which works if I use auto left and right margins without position:absolute.

Is there any way to have auto margins AND position it at the very top of the page?

My anwser

I think you have to set left and right (or maybe only left) to 50%


Written by krike

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet nisl nisl. Ut interdum libero vitae quam ultricies et lacinia elit aliquet. Praesent tincidunt, sem tempus feugiat feugiat, turpis tellus scelerisque erat, sit amet feugiat neque arcu ac lectus. Sed at mi et elit interdum scelerisque vitae eu felis.

krike has written 77 posts.