JSFiddle - React, Tailwind, and code Playground

by Reusablecode

HTML

<div style="width: 615px; margin: 0 auto 0 auto;">

        <h1 style="text-align: center;">Center Multiple Divs Demo</h1>

        <div id="parent">

            <div class="child">
                <p>This is the first box with text.</p>
            </div>

                    <div class="child">

                <p>This is another box</p>
            </div>

            <div class="child">
                <p>This is a box</p>
            </div>

            <div class="child">
                <p>This is a box</p>    
            </div>

        </div>

        <h2>The child boxes above are centered inside their parent and spread out evenly using<br />"display: inline-block" along with some typographical CSS to control the white space.</h2>
        <p style="text-align: center; padding-top: 20px;"><a href="http://www.impressivewebs.com/center-multiple-divs">&lt; Center Multiple DIVs article</a></p>

    </div>

CSS

body {
    color: #777;
}

img {
    border: none;
}

h1 {
    line-height: 1em;
    font-family: Arial, Helvetica, sans-serif;
}

h2 {
    font-family: Arial, Helvetica, sans-serif;
    margin: 20px 0 8px 0;
    text-align: center;
}

h3, h4 {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
}

p {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.5em;
    margin: 0 0 14px 0;
    text-align: left;
    padding: 5px;
}

ul {
    font-family: Arial, Helvetica, sans-serif;
    font-size: .9em;
}

    ul li {
        padding: 5px;
    }

#parent {
    border: dotted 1px #aaa;
    text-align: center;
    white-space: nowrap;
    font-size: 20px;
    letter-spacing: 35px;
    line-height: 12px;
    overflow: hidden;
    width: 615px;
}

.child {
    width: 100px;
    height: 80px;
    border: solid 1px #ccc;
    display: inline-block;
    letter-spacing: normal;
    font-size: normal;
    white-space: normal;
    text-align: normal;
    vertical-align: middle;
}

.child {
    *display: inline;
    *margin: 0 20px 0 20px;
}