Saturday, 17 August 2013

Getting div to center on page

Getting div to center on page

I need the div to be in the center of the page at all times whether user
resizes webpage or not.
I have tried using: margin: auto; margin: 0 auto; margin-left: auto;
margin-right auto;
but neither of those three worked.
HTML:
<div id="grayinnerbackground">
</div>
CSS:
div#grayinnerbackground {
margin: auto;
width:1000px;
background-color: #D9D9D9;
height: 100%;
position: fixed;
z-index: -1;
}
Here is a fiddle for an example of what I'm talking about.
http://jsfiddle.net/ymvDJ/
Thanks.

No comments:

Post a Comment