Last active
August 29, 2015 14:12
-
-
Save averyvery/04c06c6765f686568801 to your computer and use it in GitHub Desktop.
Smooth CSS property distribution with media queries
This file contains hidden or 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
=distribute($property, $min, $max, $start, $end, $precision, $metric) | |
#{$property}: $min | |
// get the range we're operating on | |
$range: $end - $start | |
// get the number of iterations we need to run by seeing how precise we should be | |
$loops: strip-units(ceil($range / $precision)) - 1 | |
// get the amount the property should be changing with each loop | |
$property_increment: ($max - $min) / $loops | |
@for $i from 1 through $loops | |
$breakpoint: $metric $start + ($i * $precision) | |
// breakpoint is the start value plus the precision amount | |
+breakpoint($breakpoint) | |
// set the property to it's min + the number of increments to add | |
#{$property}: $min + ($property_increment * $i) | |
=dist-height($property, $min, $max) | |
+distribute($property, $min, $max, $start: 400px, $end: 1400px, $precision: 50, $metric: min-height) | |
=dist-width($property, $min, $max) | |
+distribute($property, $min, $max, $start: 400px, $end: 1400px, $precision: 100, $metric: min-width) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment