JSFiddle - React, Tailwind, and code Playground

by jordenvanforeest

HTML

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>Free Grid in HTML5 and CSS3</title>
<style>

</style>

</head>
<body>

<section class="row">
<div>
<article>
<p>col 1 of 1</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of 2</p>
</article>
</div>
<div>
<article>
<p>col 2 of 2</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of 3</p>
</article>
</div>
<div>
<article>
<p>col 2 of 3</p>
</article>
</div>
<div>
<article>
<p>col 3 of 3</p>
</article>
</div>
</section>

<section class="row">
<div></div>
<div>
<article>
<p>col 1 and 2 of 3</p>
</article>
</div>
<div>
<article>
<p>col 3 of 3</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of 3</p>
</article>
</div>
<div></div>
<div>
<article>
<p>col 2 and 3 of 3</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of 4</p>
</article>
</div>
<div>
<article>
<p>col 2 of 4</p>
</article>
</div>
<div>
<article>
<p>col 3 of 4</p>
</article>
</div>
<div>
<article>
<p>col 4 of 4</p>
</article>
</div>
</section>

<section class="row">
<div></div>
<div>
<article>
<p>col 1 and 2 of 4</p>
</article>
</div>
<div>
<article>
<p>col 3 of 4</p>
</article>
</div>
<div>
<article>
<p>col 4 of 4</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of 4</p>
</article>
</div>
<div></div>
<div>
<article>
<p>col 2 and 3 of 4</p>
</article>
</div>
<div>
<article>
<p>col 4 of 4</p>
</article>
</div>
</section>


<section class="row">
<div>
<article>
<p>col 1 of 4</p>
</article>
</div>
<div>
<article>
<p>col 2 of 4</p>
</article>
</div>
<div></div>
<div>
<article>
<p>col 3 and 4 of 4</p>
</article>
</div>
</section>

<section class="row">
<div></div>
<div></div>
<div>
<article>
<p>col 1, 2 and 3 of 4</p>
</article>
</div>
<div>
<article>
<p>col 4 of 4</p>
</article>
</div>
</section>

<section class="row">
<div>
<article>
<p>col 1 of...

CSS

* {margin: 0; padding: 0;}
.row {display: table; table-layout: fixed; width: 100%;}
.row > * {display: table-cell;}
.row > :empty {display: none;}

.row > :empty + :nth-last-child(2):nth-child(2):not(:empty),
.row > :empty + :nth-last-child(1):nth-child(3):not(:empty) {width: 66.66666%;}
.gold > :empty + :nth-last-child(2):nth-child(2):not(:empty),
.gold > :empty + :nth-last-child(1):nth-child(3):not(:empty) {width: 61.8034%;}
.row > :empty + :nth-last-child(3):nth-child(2):not(:empty),
.row > :empty + :nth-last-child(2):nth-child(3):not(:empty),
.row > :empty + :nth-last-child(1):nth-child(4):not(:empty) {width: 50%;}
.row > :empty + :empty + :nth-last-child(2):nth-child(3):not(:empty),
.row > :empty + :empty + :nth-last-child(1):nth-child(4):not(:empty) {width: 75%;}
.row > :empty + :nth-last-child(4):nth-child(2):not(:empty),
.row > :empty + :nth-last-child(3):nth-child(3):not(:empty),
.row > :empty + :nth-last-child(2):nth-child(4):not(:empty),
.row > :empty + :nth-last-child(1):nth-child(5):not(:empty) {width: 40%;}
.row > :empty + :empty + :nth-last-child(3):nth-child(3):not(:empty),
.row > :empty + :empty + :nth-last-child(2):nth-child(4):not(:empty),
.row > :empty + :empty + :nth-last-child(1):nth-child(5):not(:empty) {width: 60%;}
.row > :empty + :empty + :empty + :nth-last-child(2):nth-child(4):not(:empty),
.row > :empty + :empty + :empty + :nth-last-child(1):nth-child(5):not(:empty) {width: 80%;}

article {margin:.5em;border:1px solid green;border-radius:.3em;padding:.5em; }
.gold article {background-color:gold;}