Last active
May 18, 2018 15:31
-
-
Save megclaypool/c1068825d7c5da372823dc0cd7e78b74 to your computer and use it in GitHub Desktop.
SCSS button sprite background position and size adjustments This lets you set a desired button height as a variable. Then it stretches and repositions the button background image sprite based on the desired height so that the button looks as it shou
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
$sprite-color-position: 1; | |
$sprite-section-height: 33; | |
$sprite-total-image-height: 198; | |
$desired-button-height: 66px; | |
background-position: 0 calc (-3 * #{$desired-button-height}); | |
background-size: 2px calc(#{$sprite-total-image-height}px * 2); | |
background-position: 0 calc(-1 * (#{$sprite-color-position} - 1) * #{$sprite-section-height}px / #{$desired-button-height}); | |
// background size: width height; | |
height: $desired-button-height; | |
line-height: $desired-button-height; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment