tags:

views:

92

answers:

5

How to display a div at center top position of the page, which need to be work under all size of monitors using CSS.

Mainly I get issues on IE, where not aligned properly.

A: 

CSS

div
{
margin : 0px auto;
}
Zaje
+2  A: 

For margin: 0px auto; to work width needs to be provided

style:

div#center 
{
 width: 300px;
 margin: 0px auto;
}

html:

<div id="center">content</div>
LukeP
Why do you use the unit "px" for the attribute value "0"? That's not neccessary and usually omitted.
Mef
typo, apologies. Typed in 10px at first as an example, then I've noticed OP asked for top of the page. Will leave it for reference though :D
LukeP
accepted :D I was just surprised because everybody else here was using it... so it doesn't seem well established?!
Mef
A: 

Are you comparing the rendering in both IE and another browser by switching back and forth? If so, you might be noticing a shift because of the scroll bar. IE reserves the space for the scrollbar, while browsers such as Firefox only show the window scroll when necessary.

atxryan
A: 

div#center { width: 300px; margin: 0px auto; }

not working on IE...

santose