Created
July 24, 2014 20:44
-
-
Save mirisuzanne/b49f19f30c775834f510 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.10) | |
// Compass (v1.0.0.alpha.20) | |
// Susy (v2.1.2) | |
// ---- | |
@import "susy"; | |
// Set a column-width, so we can calculate a layout for you | |
$susy: ( | |
column-width: 4em, | |
); | |
// Return a column-count based on a given width | |
@function mq-layout( | |
$mq | |
) { | |
$columns: susy-get(column-width); | |
@if $columns and comparable($mq, $columns) { | |
$gutters: susy-get(gutters) * $columns; | |
@return ceil(($mq + $gutters) / ($columns + $gutters)); | |
} @else { | |
@warn "Can't determine layout, becuse #{$mq} and #{$columns} (column-width) are not comparable."; | |
@return $susy; | |
} | |
} | |
// Set up a media-query block, using a new layout | |
@mixin mq-layout( | |
$mq, | |
$layout: false | |
) { | |
@if not $layout { | |
@if type-of($mq) == number { | |
$layout: mq-layout($mq); | |
} @else { | |
$layout: $susy; | |
} | |
} | |
$mq: if(type-of($mq) == number, 'min-width: #{$mq}', $mq); | |
@media ($mq) { | |
@include with-layout($layout) { | |
@content; | |
} | |
} | |
} | |
// DEMO! | |
.test { | |
@include span(4); | |
@include mq-layout(45em) { | |
@include span(4); | |
-susy-columns: susy-get(columns); | |
} | |
@include mq-layout(60em) { | |
@include span(4); | |
-susy-columns: susy-get(columns); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.test { | |
width: 100%; | |
float: left; | |
margin-left: 0; | |
margin-right: 0; | |
} | |
@media (min-width: 45em) { | |
.test { | |
width: 38.77551%; | |
float: left; | |
margin-right: 2.04082%; | |
-susy-columns: 10; | |
} | |
} | |
@media (min-width: 60em) { | |
.test { | |
width: 29.6875%; | |
float: left; | |
margin-right: 1.5625%; | |
-susy-columns: 13; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment