Skip to content Skip to sidebar Skip to footer

Four Divs Of Equal Height And Width

The question seems to be simple but I am not getting it done. I have a web project I am working on with body's overflow set to hidden. So I cannot put contents in the page with mor

Solution 1:

You can use a list:

<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
</ul>

CSS:

html, body, ul {
    width: 100%;
    height: 100%;
}

li {
    float: left;
    width: 50%;
    height: 50%;
}

Live demo:http://jsfiddle.net/U7WJ4/1/show/light/

Solution 2:

SOLUTION - adjust to your own need.

<styletype="text/css">#container {
        height:200px;
        width:400px;
        overflow:hidden;
        border:1px solid #000;
    }
    .item {
        float:left;
        height:100px;
        width:50%
    }
    .item-a { background-color: #CCC; }
    .item-b { background-color: #AAA; }
    .item-c { background-color: #900; }
    .item-d { background-color: #9CC; }
    .clear {
        clear:left;
    }
</style><divid="container"><divclass="item item-a">abc</div><divclass="item item-b">abc</div><divclass="item item-c">abc</div><divclass="item item-d">abc</div><divclass="clear"></div></div>

here is the equivalent table method with the same CSS as the div method

<divid="container"><tablecellpadding="0"cellspacing="0"border="0"width="100%"><tr><tdclass="item item-a">a</td><tdclass="item item-b">b</td></tr><tr><tdclass="item item-c">c</td><tdclass="item item-d">d</td></tr></table></div>

Post a Comment for "Four Divs Of Equal Height And Width"