Skip to content

Instantly share code, notes, and snippets.

@KittyGiraudel
Created August 20, 2015 10:19
Show Gist options
  • Save KittyGiraudel/05b8c31e1e355479624a to your computer and use it in GitHub Desktop.
Save KittyGiraudel/05b8c31e1e355479624a to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$row-width: 1800px;
$row-height: 420px;
$my-sass-map: (
1: 600px,
2: 430px,
3: 340px,
4: 430px
);
@function sum($args...) {
$sum: 0;
@each $arg in $args {
$sum: $sum + $arg;
}
@return $sum;
}
// Any function that you know of that would be able to add all values in all keys together.
// Ultimately I'd be checking the total sum against another variable.
@each $key, $value in $my-sass-map {
.row1-#{$key} {
// here I would have an if statement that would check the total value
// of $my-sass-maps against $row-width
@if sum(map-keys($my-sass-map)...) == $row-width {
width: ($value / $row-width) * 100%;
} @else {
@warn "Please check total widths of $my-sass-maps"
}
}
.row1-#{$key}-inner {
padding-bottom: ($row-height/$value) * 100%;
}
}
.row1-1-inner {
padding-bottom: 70%;
}
.row1-2-inner {
padding-bottom: 97.67442%;
}
.row1-3-inner {
padding-bottom: 123.52941%;
}
.row1-4-inner {
padding-bottom: 97.67442%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment