There is a nice css box-sizing property that you can set in a border-box so that the width of the width and padding are included in the width of the element. That way, you can also add as many indentation as you need for the div , without worrying about them becoming too wide.
You also do not need to wrap two lines inside a separate div - if you specify that the size of the div should be 50% wide, exactly two will fit into the line if you float them left .
HTML
<div class="box">Box 1</div> <div class="box">Box 2</div> <div class="box">Box 3</div> <div class="box">Box 4</div>
CSS
body, html { padding: 0; margin: 0; height: 100%; } .box { box-sizing: border-box; float: left; width: 50%; height: 50%; } .box:first-child { border-bottom: 1px solid black; border-right: 1px solid black; } .box:nth-child(2) { border-bottom: 1px solid black; } .box:nth-child(3) { border-right: 1px solid black; }
See http://jsfiddle.net/RBWXe/
The borders are a bit complicated because, as I understand it, you want them to be between your drawers and not touch the edges of the screen. This requires that you specify exactly which sides of each window should have a border.
A more convenient way to do this, which will also allow you to change the number of cells in your grid later, is to use background-color for the body element, which is your border color, and have the margins only half pixel narrower than 50% (using the function calc ) to place 1px space between them. See http://jsfiddle.net/yhRBy/2/
Elise source share