Skip to content

Instantly share code, notes, and snippets.

@xmalinov
Last active November 2, 2015 10:49
Show Gist options
  • Save xmalinov/535ffa0f8ee7d611f0f0 to your computer and use it in GitHub Desktop.
Save xmalinov/535ffa0f8ee7d611f0f0 to your computer and use it in GitHub Desktop.
Simple css grid
<div class="container">
<div class="grid grid-pad">
<section class="col-1-3">
text
</section>
<section class="col-1-3">
text
</section>
<section class="col-1-3">
text
</section>
</div>
<div class="grid grid-pad">
<section class="col-1-1">
text
</section>
</div>
</div>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
max-width: 940px;
margin-right: auto;
margin-left: auto;
}
/* GRID
***************/
.grid:after {
content: "";
display: table;
clear: both;
}
[class*='col-'] {
float: left;
padding-right: 20px;
}
.grid [class*='col-']:last-of-type {
padding-right: 0;
}
.col-1-1 {
width: 100%;
}
.col-2-3 {
width: 66.66%;
}
.col-1-3 {
width: 33.33%;
}
.col-1-2 {
width: 50%;
}
.col-1-4 {
width: 25%;
}
.col-3-4 {
width: 75%;
}
.col-4-5 {
width: 80%;
}
.col-1-6 {
width: 16.66%;
}
.col-1-8 {
width: 12.5%;
}
.grid-pad {
padding-left: 20px
}
.grid-pad [class*='col-'] {
padding-top: 20px;
padding-top: 20px;
}
.grid-pad [class*='col-']:last-of-type {
padding-right: 20px;
}
@media (max-width: 767px) {
[class*='col-'] {
width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment