Skip to content

Instantly share code, notes, and snippets.

@airen
Created March 27, 2015 02:02
Show Gist options
  • Save airen/86e1cfe72f60a98b2a36 to your computer and use it in GitHub Desktop.
Save airen/86e1cfe72f60a98b2a36 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div data-row>
<div data-col class="content">
<div data-row>
<div data-col="1" class="block"></div>
<div data-col="2" class="block"></div>
<div data-col="3" class="block"></div>
</div>
</div>
<div data-col class="sidebar">
<div data-col="4" class="block"></div>
<div data-col="2" class="block"></div>
</div>
</div>
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
//from: http://www.sitepoint.com/understanding-css-grid-systems/
//cw = column width
//scw = single column width (6.86666667%;)
//cs = column span(1~12)
//m = margin (1.6%)
//mc = maximum columns (12)
//scw = (100 - (m * (mc -1 ))) / mc
//cw = (scw * cs) + (m * (cs - 1))
@mixin col-width($loop:false,$cs:12,$mc:12,$m: 1.6%){
@if $loop {
@for $i from 1 through $mc {
[data-col="#{$i}"]{
width: (((100 - ($m * ($mc - 1))) / $mc) * $i) + ($m * ($i - 1));
}
}
} @else {
width: (((100 - ($m * ($mc - 1))) / $mc) * $cs) + ($m * ($cs - 1));
}
}
.content {
@include col-width(false,9,12);
}
.sidebar {
@include col-width(false,3,12);
}
@include col-width(true,6,6,1.6%);
[data-row],
[data-col]{
box-sizing: border-box;
}
[data-row]{
margin-bottom: 10px;
&:before,
&:after {
content:"";
display: table;
}
&:after {
clear:both;
}
&:last-child{
margin-bottom:0;
}
}
[data-col]{
min-height: 50px;
background-color: #eee;
border-radius: 5px;
float: left;
position: relative;
display: block;
padding: 5px;
}
[data-col] + [data-col] {
margin-left: 1.6%;
}
[data-col] [data-col]{
background-color: #333;
}
.content {
width: 74.6%;
}
.sidebar {
width: 23.8%;
}
[data-col="1"] {
width: 15.33333333%;
}
[data-col="2"] {
width: 32.26666667%;
}
[data-col="3"] {
width: 49.2%;
}
[data-col="4"] {
width: 66.13333333%;
}
[data-col="5"] {
width: 83.06666667%;
}
[data-col="6"] {
width: 100%;
}
[data-row],
[data-col] {
box-sizing: border-box;
}
[data-row] {
margin-bottom: 10px;
}
[data-row]:before, [data-row]:after {
content: "";
display: table;
}
[data-row]:after {
clear: both;
}
[data-row]:last-child {
margin-bottom: 0;
}
[data-col] {
min-height: 50px;
background-color: #eee;
border-radius: 5px;
float: left;
position: relative;
display: block;
padding: 5px;
}
[data-col] + [data-col] {
margin-left: 1.6%;
}
[data-col] [data-col] {
background-color: #333;
}
<div data-row>
<div data-col class="content">
<div data-row>
<div data-col="1" class="block"></div>
<div data-col="2" class="block"></div>
<div data-col="3" class="block"></div>
</div>
</div>
<div data-col class="sidebar">
<div data-col="4" class="block"></div>
<div data-col="2" class="block"></div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment