I've got an problem. I have the html code like this:
<div id="main_content" >
<div id="container">
</div>
</div>
The css like this:
#main_content {
top: 160px;
left: 160px;
width: 800px;
min-height: 500px;
height: auto;
background-color: #2185C5;
position: relative;
}
#container {
width: auto;
height: auto;
margin: 0 auto;
padding: 10px;
position: relative;
}
I suppose that the #container will be centered within #main_content. However, it is not. I just want to find out the reason and how to make it centered.
I would try defining a more specific width, for starters. It's hard to center something that already spans the entire width:
This will work fine i think though you might need to reset "top:200px;" according to your need--
Without setting the
Width
it will get the maximum width it can get. So you cannot see thatDiv
has centered.