Skip to content

Instantly share code, notes, and snippets.

@imathis
Created July 19, 2009 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save imathis/149814 to your computer and use it in GitHub Desktop.
Save imathis/149814 to your computer and use it in GitHub Desktop.
//**
Example use:
a
+sprite-bg("icons-32.png")
a.twitter
+sprite-column(1)
a.facebook
+sprite-column(2)
...
!sprite_default_size ||= 32px
!sprite_default_margin ||= 0px
// Sets rules common for all sprites
=sprite-bg(!img, !width = !sprite_default_size, !height = !width)
:background= url(!img) "no-repeat"
:width= !width
:height= !height
:overflow= "hidden"
// Allows horizontal sprite positioning
=sprite-column(!col, !width = !sprite_default_size, !margin = !sprite_default_margin)
!x = ((!col - 1) * -!width) - ((!col - 1) * !margin)
:background-position= !x 0
// Allows vertical sprite positioning
=sprite-row(!row, !height = !sprite_default_size, !margin = !sprite_default_margin)
!y = ((!row - 1) * -!height) - ((!row - 1) * !margin)
:background-position= 0 !y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment