velu
velu

Reputation: 1

how to display a div at center top of the page

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.

Upvotes: 0

Views: 1166

Answers (4)

Santhosh
Santhosh

Reputation: 20456

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

not working on IE...

Upvotes: 0

Ryan Joy
Ryan Joy

Reputation: 3039

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.

Upvotes: 0

LukeP
LukeP

Reputation: 10422

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>

Upvotes: 3

Zaje
Zaje

Reputation: 2309

CSS

div
{
margin : 0px auto;
}

Upvotes: 0

Related Questions