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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. @mixin transform($func) {
  62. -moz-transform: $func;
  63. -ms-transform: $func;
  64. -webkit-transform: $func;
  65. -o-transform: $func;
  66. transform: $func;
  67. }
  68. @mixin transition($transition...) {
  69. -moz-transition: $transition;
  70. -o-transition: $transition;
  71. -webkit-transition: $transition;
  72. transition: $transition;
  73. }
  74. /**
  75. * Mixin styling placeholder
  76. **/
  77. @mixin placeholder() {
  78. $selectors: (
  79. "::-webkit-input-placeholder",
  80. "::-moz-placeholder",
  81. ":-moz-placeholder",
  82. ":-ms-input-placeholder"
  83. );
  84. @each $selector in $selectors {
  85. #{$selector} {
  86. @content;
  87. }
  88. }
  89. }
  90. @mixin box-shadow($h, $y, $blur, $color, $inset: false) {
  91. @if $inset {
  92. -webkit-box-shadow: inset $h $y $blur $color;
  93. -moz-box-shadow: inset $h $y $blur $color;
  94. box-shadow: inset $h $y $blur $color;
  95. } @else {
  96. -webkit-box-shadow: $h $y $blur $color;
  97. -moz-box-shadow: $h $y $blur $color;
  98. box-shadow: $h $y $blur $color;
  99. }
  100. }
  101. @mixin no-box-shadow {
  102. -webkit-box-shadow: none;
  103. -moz-box-shadow: none;
  104. box-shadow: none;
  105. }
  106. @mixin box-sizing($box-model) {
  107. -webkit-box-sizing: $box-model; // Safari <= 5
  108. -moz-box-sizing: $box-model; // Firefox <= 19
  109. box-sizing: $box-model;
  110. }
  111. @mixin border-radius($radius) {
  112. -webkit-border-radius: $radius;
  113. border-radius: $radius;
  114. /* stops bg color from leaking outside the border: */
  115. background-clip: padding-box;
  116. }
  117. @mixin opacity($opacity) {
  118. opacity: $opacity;
  119. $opacity-ie: $opacity * 100;
  120. -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=$opacity-ie);
  121. filter: alpha(opacity=$opacity-ie); //IE8
  122. }
  123. @mixin text-truncate {
  124. display: block;
  125. overflow: hidden;
  126. text-overflow: ellipsis;
  127. white-space: nowrap;
  128. }