css

Css – How to place a div at top center position of a page using CSS

css

I am not able to place a div at the top center of a page. I am using CSS for this but nothing works here.

#loader {  position: relative;  margin: 0 auto;  text-align: left;  clear: left;  height: auto;  z-index: 0;}
<body>  <div id="loader" style='display: none'><img src='img/basic/loader4.gif' /></div></body>

I had already given 2 hours on this but still not able to figure it out.

Best Solution

First remove display:none; from your div with id=loader & add text-align:center; to it

#loader{      position:relative;    margin:0 auto;    clear:left;    height:auto;    z-index: 0;    text-align:center;/* Add This*/}​

Working demo: http://jsfiddle.net/surendraVsingh/FCEhD/