I want to create a Responsive 12 column grid system
using CSS FLEXBOX
for making my website responsive. I don't want to use any css framework instead I want to use my own 12 column grid system
and with writing my own css. I want class names
like this which are listed below. Any help would be appreciated.
I tried something like below. Please correct me.
*,
*::after,
*::before {
box-sizing: border-box;
}
.container,
.container-full {
width: 100%;
margin: auto;
padding: 0 1rem;
}
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12 {
padding: 1rem;
border: 1px solid #ccc;
}
.col-1 {
max-width: 8.333333333333333%;
}
.col-2 {
max-width: 16.66666666666667%;
}
.col-3 {
max-width: 25%;
}
.col-4 {
max-width: 33.333333333333333%;
}
.col-5 {
max-width: 41.66666666666667%;
}
.col-6 {
max-width: 50%;
}
.col-7 {
max-width: 58.333333333333333%;
}
.col-8 {
max-width: 66.66666666666666%;
}
.col-9 {
max-width: 75%;
}
.col-10 {
max-width: 83.333333333333333%;
}
.col-11 {
max-width: 91.66666666666666%;
}
.col-12 {
max-width: 100%;
}
The principle is rather straightforward
.flex-row
)flex-basis
instead ofmax-width
. Combined withflex: 1
the flexbox mechanism takes care of space distribution between the child elements.snippet so you have some base to toy with...
BTW, notice the responsive base font size inside 'eye-candy'