JSFiddle - React, Tailwind, and code Playground
by karthick6891
HTML
<!-- sample responsive template -->
<h3>Grid3</h3>
<div class="wrapper grid3">
<article class="col">
Column 1
</article>
<article class="col">
Column 2
</article>
<article class="col">
Column 3
</article>
<article class="col">
Column 4
</article>
<article class="col">
Column 5
</article>
<article class="col">
Column 6
</article>
</div>
CSS
body {
background: #fff;
color: #666;
font: 85%/140% Arial, Helvetica, sans-serif;
width: 800px;
max-width: 96%;
margin: 0 auto;
}
/* set html5 elements to block */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
#pagewrap {
width: 978px;
max-width: 96%;
margin: 0 auto;
}
.wrapper {
overflow: hidden;
}
/************************************************************************************
COLUMN
*************************************************************************************/
.col {
background: #eee;
float: left;
margin-left: 3.2%;
margin-bottom: 30px;
}
.fullwidth .col {
float: none;
margin-left: 0;
}
/* grid4 col */
.grid4 .col {
width: 22.6%;
}
/* grid3 col */
.grid3 .col {
width: 31.2%;
background-color:red;
}
/* grid2 col */
.grid2 .col {
width: 48.4%;
}
/* clear col */
.grid4 .col:nth-of-type(4n+1),
.grid3 .col:nth-of-type(3n+1),
.grid2 .col:nth-of-type(2n+1) {
margin-left: 0;
clear: both;
}
/************************************************************************************
MEDIA QUERIES
*************************************************************************************/
/* reset cols to 3-column */
@media screen and (max-width: 740px) {
}
/* reset cols to 2-column */
@media screen and (max-width: 600px) {
/* grid3 */
.grid3 .col {
width: 48.4%;
background-color:green;
}
.grid3 .col:nth-of-type(3n+1) {
margin-left: 3.2%;
clear: none;
}
.grid3 .col:nth-of-type(2n+1) {
margin-left: 0;
clear: left;
}
}
/* reset cols to fullwidth */
@media screen and (max-width: 400px) {
/* grid4 */
.col {
width: 100% !important;
margin-left: 0 !important;
clear: none !important;
background-color: #eee !important;
}
}