Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a nice css property <code>box-sizing</code> that you can set to <code>border-box</code> so that the widths of borders and padding are <em>included</em> in the width of an element. This way you can also add as much padding as you need to your <code>div</code>s without worrying that they become too wide.</p> <p>You also don't actually need to wrap your two rows inside separate <code>div</code>s -- if you specify that a <code>div</code> should be 50% wide, exactly two will fit in a row if you <code>float</code> them <code>left</code>.</p> <p>HTML</p> <pre><code>&lt;div class="box"&gt;Box 1&lt;/div&gt; &lt;div class="box"&gt;Box 2&lt;/div&gt; &lt;div class="box"&gt;Box 3&lt;/div&gt; &lt;div class="box"&gt;Box 4&lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>body, html { padding: 0; margin: 0; height: 100%; } .box { box-sizing: border-box; float: left; width: 50%; height: 50%; } /* This is one way of adding borders, if you *always* know that you have exactly 4 cells aligned like this */ .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; } </code></pre> <p>See <a href="http://jsfiddle.net/RBWXe/" rel="nofollow">http://jsfiddle.net/RBWXe/</a></p> <p>The borders are a bit tricky, because as I understand, you want them in between your boxes, and not touching the edges of the screen. This requires you to specify exactly which sides of each box should have a border.</p> <p>A fancier way of doing this, which would also allow you to change the number of boxes in your grid later, is to use a <code>background-color</code> for the <code>body</code> element which is your border colour, and have the boxes just half a pixel narrower than 50% (using the <code>calc</code> function), to accommodate the 1px space in between them. See <a href="http://jsfiddle.net/yhRBy/2/" rel="nofollow">http://jsfiddle.net/yhRBy/2/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload