Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. If you use sprites... sticking to a grid system makes it so much easier in
  2. SASS... I didnt do it on the last project I used a big sprite sheet on...
  3. but I will do it on the next one having played with it.
  4.  
  5. Basically, I made a spritesheet where everything's top-left was on a 20x20
  6. grid corner. Some things took up multiple grid squares, but the top-left
  7. was always in a grid corner. Then i just a mixin with variables for the
  8. column and row of the sprite
  9.  
  10. Then, in SASS/SCSS
  11.  
  12. $grid_spacing = 20;
  13.  
  14. @mixin sprite($x, $y) {
  15. background-image: url(mysprite.png)
  16. background-position: -#{$x*!grid_spacing} -#{$y*!grid_spacing}
  17. }
  18.  
  19. .mySpriteButton
  20. @include sprite(3, 5)
  21. width: 200px
  22. height: 50px
Add Comment
Please, Sign In to add comment