You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_mixins.scss 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /**
  2. * Animation mixin.
  3. */
  4. @mixin animation($animate...) {
  5. $max: length($animate);
  6. $animations: '';
  7. @for $i from 1 through $max {
  8. $animations: #{$animations + nth($animate, $i)};
  9. @if $i < $max {
  10. $animations: #{$animations + ", "};
  11. }
  12. }
  13. -webkit-animation: $animations;
  14. -moz-animation: $animations;
  15. -o-animation: $animations;
  16. animation: $animations;
  17. }
  18. @mixin flex() {
  19. display: -webkit-box;
  20. display: -moz-box;
  21. display: -ms-flexbox;
  22. display: -webkit-flex;
  23. display: flex;
  24. }
  25. /**
  26. * Keyframes mixin.
  27. */
  28. @mixin keyframes($animationName) {
  29. @-webkit-keyframes #{$animationName} {
  30. @content;
  31. }
  32. @-moz-keyframes #{$animationName} {
  33. @content;
  34. }
  35. @-o-keyframes #{$animationName} {
  36. @content;
  37. }
  38. @keyframes #{$animationName} {
  39. @content;
  40. }
  41. }
  42. @mixin circle($diameter) {
  43. width: $diameter;
  44. height: $diameter;
  45. border-radius: 50%;
  46. }
  47. /**
  48. * Absolute position the element at the top left corner
  49. **/
  50. @mixin topLeft() {
  51. position: absolute;
  52. top: 0;
  53. left: 0;
  54. }
  55. @mixin absoluteAligning() {
  56. top: 50%;
  57. left: 50%;
  58. position: absolute;
  59. @include transform(translate(-50%, -50%));
  60. }
  61. /**
  62. * Defines the maximum width and height
  63. **/
  64. @mixin maxSize($value) {
  65. max-width: $value;
  66. max-height: $value;
  67. }
  68. @mixin transform($func) {
  69. -moz-transform: $func;
  70. -ms-transform: $func;
  71. -webkit-transform: $func;
  72. -o-transform: $func;
  73. transform: $func;
  74. }
  75. @mixin transition($transition...) {
  76. -moz-transition: $transition;
  77. -o-transition: $transition;
  78. -webkit-transition: $transition;
  79. transition: $transition;
  80. }
  81. /**
  82. * Mixin styling placeholder
  83. **/
  84. @mixin placeholder() {
  85. $selectors: (
  86. "::-webkit-input-placeholder",
  87. "::-moz-placeholder",
  88. ":-moz-placeholder",
  89. ":-ms-input-placeholder"
  90. );
  91. @each $selector in $selectors {
  92. #{$selector} {
  93. @content;
  94. }
  95. }
  96. }
  97. @mixin box-shadow($h, $y, $blur, $color, $inset: false) {
  98. @if $inset {
  99. -webkit-box-shadow: inset $h $y $blur $color;
  100. -moz-box-shadow: inset $h $y $blur $color;
  101. box-shadow: inset $h $y $blur $color;
  102. } @else {
  103. -webkit-box-shadow: $h $y $blur $color;
  104. -moz-box-shadow: $h $y $blur $color;
  105. box-shadow: $h $y $blur $color;
  106. }
  107. }
  108. @mixin no-box-shadow {
  109. -webkit-box-shadow: none;
  110. -moz-box-shadow: none;
  111. box-shadow: none;
  112. }
  113. @mixin box-sizing($box-model) {
  114. -webkit-box-sizing: $box-model; // Safari <= 5
  115. -moz-box-sizing: $box-model; // Firefox <= 19
  116. box-sizing: $box-model;
  117. }
  118. @mixin border-radius($radius) {
  119. -webkit-border-radius: $radius;
  120. border-radius: $radius;
  121. /* stops bg color from leaking outside the border: */
  122. background-clip: padding-box;
  123. }
  124. @mixin opacity($opacity) {
  125. opacity: $opacity;
  126. $opacity-ie: $opacity * 100;
  127. -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=$opacity-ie);
  128. filter: alpha(opacity=$opacity-ie); //IE8
  129. }
  130. @mixin text-truncate {
  131. display: block;
  132. overflow: hidden;
  133. text-overflow: ellipsis;
  134. white-space: nowrap;
  135. }
  136. /**
  137. * Creates a semi-transparent background with the given color and alpha
  138. * (opacity) value.
  139. */
  140. @mixin transparentBg($color, $alpha) {
  141. background-color: rgba(red($color), green($color), blue($color), $alpha);
  142. }