Skip to content

Instantly share code, notes, and snippets.

@jnowland
Last active August 29, 2015 14:01
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 jnowland/b43cbb00549b308d6100 to your computer and use it in GitHub Desktop.
Save jnowland/b43cbb00549b308d6100 to your computer and use it in GitHub Desktop.
Attempting to set a negative margin-top of half height using sass maps. The units returning don't appear to be a string or integer.
// Generated from spritesmith via gulp
$sprites: (
arrow-right-blue-withShadow: (
x: 0px,
y: 114px,
offset_x: 0px,
offset_y: -114px,
width: 13px,
height: 19px,
total_width: 239px,
total_height: 799px,
image: '../img/icon-sprite.png'
),
arrow-right-white-withShadow: (
x: 0px,
y: 233px,
offset_x: 0px,
offset_y: -233px,
width: 13px,
height: 19px,
total_width: 239px,
total_height: 799px,
image: '../img/icon-sprite.png'
),
club-evolution-191x40: (
x: 0px,
y: 596px,
offset_x: 0px,
offset_y: -596px,
width: 191px,
height: 40px,
total_width: 239px,
total_height: 799px,
image: '../img/icon-sprite.png'
),
);
@function sprite($sprite, $attribute) {
@return map-get(map-get($sprites, $sprite), $attribute),
}
/* */
$iconHeightSprite: sprite(arrow-right-blue-withShadow , 'height');
/*
Failed attempts:
@function strip-units($number) {
@return $number / ($number * 0 + 1);
}
$iconHeightSprite: unquote($iconHeightSprite);
@warn strip-units( $iconHeightSprite ); // error scss/example.scss (Line 50: Undefined operation: "19px times 0".)
*/
$iconHalfHeight: $iconHeightSprite/2;
.example {
margin-top: $iconHalfHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment