grid.scss 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* ==========================================================================
  2. Grid mixins
  3. ========================================================================== */
  4. /*
  5. Define number of columns in the grid
  6. Common values would be 12, 16 or 24
  7. ========================================================================== */
  8. $width: 100%;
  9. $def_grid: 12;
  10. $margin: 0;
  11. @mixin container(){
  12. margin:0 auto;
  13. width:$width;
  14. }
  15. /*
  16. Works out the width of elements based on total number of columns and width
  17. number of columns being displayed. Removes 20px for margins.
  18. ========================================================================== */
  19. @mixin grid($grid:$def_grid,$cols:'',$float:left,$display:inline){
  20. display:$display;
  21. float:$float;
  22. width:(100%/$grid * $cols) - ($margin * 2);
  23. }
  24. /*
  25. Add x amount of column padding before an element
  26. Example: @include prefix(1,12);
  27. ========================================================================== */
  28. @mixin prefix($grid:$def_grid,$cols:''){
  29. margin-left:(100%/$grid * $cols);
  30. }
  31. /*
  32. Add x amount of column padding after an element
  33. Example: @include suffix(2,12);
  34. ========================================================================== */
  35. @mixin suffix($grid:$def_grid,$cols:''){
  36. margin-right:(100%/$grid * $cols);
  37. }
  38. /*
  39. Remove left margin
  40. Example: @include first;
  41. ========================================================================== */
  42. @mixin first(){
  43. margin-left:0;
  44. }
  45. /*
  46. Remove right margin
  47. Example: @include last;
  48. ========================================================================== */
  49. @mixin last(){
  50. margin-right:0;
  51. }
  52. /*
  53. Push an element x amount of column(s) to the right
  54. Example: @include push(2,12);
  55. ========================================================================== */
  56. @mixin push($grid:$def_grid,$move:'') {
  57. position:relative;
  58. left:(100%/$grid * $move);
  59. }
  60. /*
  61. Pull an element x amount of column(s) to the left
  62. Example: @include pull(1,12);
  63. ========================================================================== */
  64. @mixin pull($grid:$def_grid,$move:''){
  65. position:relative;
  66. left:(100%/$grid * $move) * -1;
  67. }