Similar Question:
Best way to center a <div> on a page vertically and horizontally?
On my website landing page, the Container
DIV occupies 100% of the Height and Width. While I have successfully centered the InnerContainer
horizontally, I am facing difficulties in aligning it vertically. I have tried adjusting various properties with little success.
I have created a similar example on http://jsfiddle.net/cwkzq/12/ but I can't seem to pinpoint where I am going wrong. Any assistance would be greatly appreciated.
CSS Code
html, body,form { height: 100%; }
body { margin: 0; padding: 0; border: 1; background-color:Aqua; }
.Container { width: 100%;height: 100%; padding: 0; font-size: 12px; border:1px solid green;
vertical-align: middle; }
.InnerContainer
{ vertical-align: middle; width: 400px;height: 350px; border-left:1px solid;
border-right:1px solid; border-color:#f5f5f5;margin: 0 auto; padding: 0;
font-size: 12px; background-color:Red;
}
HTML CODE
<!-- Container -->
<div class="Container">
<div class="InnerContainer">
<!-- TopMenu Bar -->
<div class="colorBar">
</div>
<!-- TopMenu Bar -->
<!-- Middle Part -->
<div class="MiddleWrapper">
<!-- Left Title -->
<div class="Title">
</div>
<!-- Left Title -->
<!-- Large Image -->
<div class="ImageLeftWrapper">
</div>
<!-- Large Image -->
<!-- Logo Wrapper -->
<div class="LogoWrapper">
</div>
<!-- Logo Wrapper -->
<!-- Page Text Area -->
<div class="PageText">
</div>
<!-- Page Text Area -->
<!-- Search Bar -->
<div class="SearchBar">
</div>
<!-- Search Bar -->
<!-- Banner Images -->
<div class="BannerImageWrapper">
</div>
<!-- Banner Images -->
</div>
<!-- Middle Part -->
<!-- Menu Wrapper -->
<div class="MenuWrapper">
</div>
<!-- Menu Wrapper -->
<!-- Footer Section -->
<div class="FooterWrapper">
</div>
<!-- Footer Section -->
</div>
</div>
<!-- Container -->
In most examples online, the Container DIV has a fixed width and height, whereas in my case, it is set to 100% width and height.