Skip to content

Instantly share code, notes, and snippets.

@shaunjanssens
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaunjanssens/2d0fbbb95aae67794cd1 to your computer and use it in GitHub Desktop.
Save shaunjanssens/2d0fbbb95aae67794cd1 to your computer and use it in GitHub Desktop.
Grid met css3's calc()
.container {
max-width: 1140px;
margin-left: auto;
margin-right: auto;
}
.row:before,
.row:after {
content: " ";
display: table;
}
.row:after {
clear: both;
}
.col {
float: left;
box-sizing: border-box;
}
.col-1 {
width: calc(1/12 * 100%);
}
.col-2 {
width: calc(2/12 * 100%);
}
.col-3 {
width: calc(3/12 * 100%);
}
.col-4 {
width: calc(4/12 * 100%);
}
.col-5 {
width: calc(5/12 * 100%);
}
.col-6 {
width: calc(6/12 * 100%);
}
.col-7 {
width: calc(7/12 * 100%);
}
.col-8 {
width: calc(8/12 * 100%);
}
.col-9 {
width: calc(9/12 * 100%);
}
.col-10 {
width: calc(10/12 * 100%);
}
.col-11 {
width: calc(11/12 * 100%);
}
.col-12 {
width: 100%;
}
<div class="container">
<div class="row">
<div class="col col-6">
</div>
<div class="col col-6">
</div>
</div>
<div class="row">
<div class="col col-4">
</div>
<div class="col col-4">
</div>
<div class="col col-4">
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment