The easy way to do this?
Simply put everything you want aligned in an another div, and on the html page write.
code:
<div align='center>
<div class='container>
</div>
</div>
Saves you from a bunch of problems to center-it horizontally. As for the vertical, depending on how big your container is (e.g. 40%), you would simply have to do : (100% - 40%) / 2, and then use the result ( 30% here) and use it as top in your position propriety.
code:
#container
{
position:relative;
top:30%;
}