jordazzle jordazzle - 1 year ago 79
HTML Question

Horizontally Center two divs within a container div

I found this similar question but could not get it to work.

I have two div containers labelled in my CSS as "box" and I can't get them to be centered within their parent div (labelled as "wrapper" in my CSS)

Here's my code:


.wrapper {
display: inline-block;
margin: 0 auto;

.box {
display: inline-block;
height: 370px;
padding-left: 5px;
padding-right: 5px;
vertical-align: top;

Any help would be greatly appreciated!

Answer Source

You should change some styling for the wrapper and you'll be good:

.wrapper {
    display: block;
    text-align: center;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download