_mixins.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. /// Adds a browser prefix to the property
  2. /// @param {*} $property Property
  3. /// @param {*} $value Value
  4. @mixin clamp($lines: 2) {
  5. display: -webkit-box;
  6. overflow: hidden;
  7. -webkit-line-clamp: $lines;
  8. -webkit-box-orient: vertical;
  9. }
  10. @mixin css3-prefix($property, $value) {
  11. -webkit-#{$property}: #{$value};
  12. -khtml-#{$property}: #{$value};
  13. -moz-#{$property}: #{$value};
  14. -ms-#{$property}: #{$value};
  15. -o-#{$property}: #{$value};
  16. #{$property}: #{$value};
  17. }
  18. /// Background Gradient
  19. /// @param {Color} $startColor [#3C3C3C] - Start Color
  20. /// @param {Color} $endColor [#999999] - End Color
  21. @mixin background-gradient($startColor: #3C3C3C, $endColor: #999999) {
  22. background-color: $startColor;
  23. background-image: -webkit-gradient(linear, left top, left bottom, from($startColor), to($endColor));
  24. background-image: -webkit-linear-gradient(top, $startColor, $endColor);
  25. background-image: -moz-linear-gradient(top, $startColor, $endColor);
  26. background-image: -ms-linear-gradient(top, $startColor, $endColor);
  27. background-image: -o-linear-gradient(top, $startColor, $endColor);
  28. background-image: linear-gradient(top, $startColor, $endColor);
  29. filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$startColor}', endColorStr='#{$endColor}');
  30. }
  31. /// Background Horizontal
  32. /// @param {Color} $startColor [#3C3C3C] - Start Color
  33. /// @param {Color} $endColor [#999999] - End Color
  34. @mixin background-horizontal($startColor: #3C3C3C, $endColor: #999999) {
  35. background-color: $startColor;
  36. background-image: -webkit-gradient(linear, left top, right top, from($startColor), to($endColor));
  37. background-image: -webkit-linear-gradient(left, $startColor, $endColor);
  38. background-image: -moz-linear-gradient(left, $startColor, $endColor);
  39. background-image: -ms-linear-gradient(left, $startColor, $endColor);
  40. background-image: -o-linear-gradient(left, $startColor, $endColor);
  41. background-image: linear-gradient(left, $startColor, $endColor);
  42. filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$startColor}', endColorStr='#{$endColor}', gradientType='1');
  43. }
  44. /// Background Radial
  45. /// @param {Color} $startColor [#3C3C3C] - Start Color
  46. /// @param {Percentage} $startPos [0%] - Start position
  47. /// @param {Color} $endColor [#999999] - End Color
  48. /// @param {Percentage} $endPos [100%] - End position
  49. @mixin background-radial($startColor: #FFFFFF, $startPos: 0%, $endColor: #000000, $endPos:100%) {
  50. background: -moz-radial-gradient(center, ellipse cover, $startColor $startPos, $endColor $endPos);
  51. background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop($startPos,$startColor), color-stop($endPos,$endColor));
  52. background: -webkit-radial-gradient(center, ellipse cover, $startColor $startPos,$endColor $endPos);
  53. background: -o-radial-gradient(center, ellipse cover, $startColor $startPos,$endColor $endPos);
  54. background: -ms-radial-gradient(center, ellipse cover, $startColor $startPos,$endColor $endPos);
  55. background: radial-gradient(ellipse at center, $startColor $startPos,$endColor $endPos);
  56. }
  57. /// Background Size
  58. /// @param {Size} $width [100%] - Width
  59. /// @param {Size} $width [$width] - Height
  60. /// @require {mixin} css3-prefix
  61. @mixin background-size($width: 100%, $height: $width) {
  62. @if type-of($width) == 'number' and $height != null {
  63. @include css3-prefix('background-size', $width $height);
  64. } @else {
  65. @include css3-prefix('background-size', $width);
  66. }
  67. }
  68. /// Background Color Opacity
  69. /// @param {Color} $color [100%] - Color
  70. /// @param {Double} $opacity [0.85] - Opacity
  71. @mixin background-opacity($color: #000, $opacity: 0.85) {
  72. background: $color;
  73. background: rgba($color, $opacity);
  74. }
  75. /// Border Radius
  76. /// @param {Size} $radius [5px] - Radius
  77. /// @require {mixin} css3-prefix
  78. @mixin border-radius($radius: 5px) {
  79. @include css3-prefix('border-radius', $radius);
  80. }
  81. /// Border Radius Separate
  82. /// @param {Size} $topLeftRadius [5px] - Top Left
  83. /// @param {Size} $topRightRadius [5px] - Top Right
  84. /// @param {Size} $bottomLeftRadius [5px] - Bottom Left
  85. /// @param {Size} $bottomRightRadius [5px] - Bottom Right
  86. @mixin border-radius-separate($topLeftRadius: 5px, $topRightRadius: 5px, $bottomLeftRadius: 5px, $bottomRightRadius: 5px) {
  87. -webkit-border-top-left-radius: $topLeftRadius;
  88. -webkit-border-top-right-radius: $topRightRadius;
  89. -webkit-border-bottom-right-radius: $bottomRightRadius;
  90. -webkit-border-bottom-left-radius: $bottomLeftRadius;
  91. -moz-border-radius-topleft: $topLeftRadius;
  92. -moz-border-radius-topright: $topRightRadius;
  93. -moz-border-radius-bottomright: $bottomRightRadius;
  94. -moz-border-radius-bottomleft: $bottomLeftRadius;
  95. border-top-left-radius: $topLeftRadius;
  96. border-top-right-radius: $topRightRadius;
  97. border-bottom-right-radius: $bottomRightRadius;
  98. border-bottom-left-radius: $bottomLeftRadius;
  99. }
  100. /// Box
  101. /// @param {*} $orient [horizontal] - Orientation
  102. /// @param {*} $pack [center] - Pack
  103. /// @param {*} $align [center] - Align
  104. /// @require {mixin} css3-prefix
  105. @mixin box($orient: horizontal, $pack: center, $align: center) {
  106. display: -webkit-box;
  107. display: -moz-box;
  108. display: box;
  109. @include css3-prefix('box-orient', $orient);
  110. @include css3-prefix('box-pack', $pack);
  111. @include css3-prefix('box-align', $align);
  112. }
  113. /// Box RGBA
  114. /// @param {Integer} $r [60] - Red
  115. /// @param {Integer} $g [3] - Green
  116. /// @param {Integer} $b [12] - Blue
  117. /// @param {Double} $opacity [0.23] - Opacity
  118. /// @param {Color} $color [#3C3C3C] - Color
  119. @mixin box-rgba($r: 60, $g: 3, $b: 12, $opacity: 0.23, $color: #3C3C3C) {
  120. background-color: transparent;
  121. background-color: rgba($r, $g, $b, $opacity);
  122. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$color}',endColorstr='#{$color}');
  123. zoom: 1;
  124. }
  125. /// Box Shadow
  126. /// @param {Size} $x [2px] - X
  127. /// @param {Size} $y [2px] - Y
  128. /// @param {Size} $blur [5px] - Blur
  129. /// @param {Color} $color [rgba(0,0,0,.4)] - Color
  130. /// @param {Boolean} $inset - Inset
  131. @mixin box-shadow($x: 2px, $y: 2px, $blur: 5px, $color: rgba(0,0,0,.4), $inset: "") {
  132. @if ($inset != "") {
  133. @include css3-prefix('box-shadow', $inset $x $y $blur $color);
  134. } @else {
  135. @include css3-prefix('box-shadow', $x $y $blur $color);
  136. }
  137. }
  138. /// Box Sizing
  139. /// @param {*} $type [border-box] - Type
  140. /// @require {mixin} css3-prefix
  141. @mixin box-sizing($type: border-box) {
  142. @include css3-prefix('box-sizing', $type);
  143. }
  144. /// Columns
  145. /// @param {Integer} $count [3] - Count
  146. /// @param {Integer} $gap [10] - Gap
  147. /// @require {mixin} css3-prefix
  148. @mixin columns($count: 3, $gap: 10) {
  149. @include css3-prefix('column-count', $count);
  150. @include css3-prefix('column-gap', $gap);
  151. }
  152. /// Double Borders
  153. /// @param {Color} $colorOne [#3C3C3C] - Color One
  154. /// @param {Color} $colorTwo [#999999] - Color Two
  155. /// @param {Size} $radius [0] - Radius
  156. /// @require {mixin} css3-prefix
  157. /// @require {mixin} border-radius
  158. @mixin double-borders($colorOne: #3C3C3C, $colorTwo: #999999, $radius: 0) {
  159. border: 1px solid $colorOne;
  160. @include css3-prefix('box-shadow', 0 0 0 1px $colorTwo);
  161. @include border-radius( $radius );
  162. }
  163. /// Flex
  164. /// @param {Integer} $value [1] - Value
  165. /// @require {mixin} css3-prefix
  166. @mixin flex($value: 1) {
  167. @include css3-prefix('box-flex', $value);
  168. }
  169. /// Flip
  170. /// @param {Double} $scaleX [-1] - ScaleX
  171. /// @require {mixin} css3-prefix
  172. @mixin flip($scaleX: -1) {
  173. @include css3-prefix('transform', scaleX($scaleX));
  174. filter: "FlipH";
  175. -ms-filter: "FlipH";
  176. }
  177. /// Font Face
  178. /// @param {Font} $fontFamily [myFont] - Font Family
  179. /// @param {String} $eotFileSrc ['myFont.eot'] - Eot File Source
  180. /// @param {String} $woffFileSrc ['myFont.woff'] - Woff File Source
  181. /// @param {String} $ttfFileSrc ['myFont.ttf'] - Ttf File Source
  182. /// @param {String} $svgFileSrc ['myFont.svg'] - Svg File Source
  183. @mixin font-face($fontFamily: myFont, $eotFileSrc: 'myFont.eot', $woffFileSrc: 'myFont.woff', $ttfFileSrc: 'myFont.ttf', $svgFileSrc: 'myFont.svg', $svgFontID: '#myFont') {
  184. font-family: $fontFamily;
  185. src: url($eotFileSrc) format('eot'),
  186. url($woffFileSrc) format('woff'),
  187. url($ttfFileSrc) format('truetype'),
  188. url($svgFileSrc + $svgFontID) format('svg');
  189. }
  190. /// Opacity
  191. /// @param {Double} $opacity [0.5] - Opacity
  192. /// @require {mixin} css3-prefix
  193. @mixin opacity($opacity: 0.5) {
  194. $opacityMultiplied: ($opacity * 100);
  195. filter: alpha(opacity=$opacityMultiplied);
  196. -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + $opacityMultiplied + ")";
  197. @include css3-prefix('opacity', $opacity);
  198. }
  199. /// Outline Radius
  200. /// @param {Size} $radius [5px] - Radius
  201. /// @require {mixin} css3-prefix
  202. @mixin outline-radius($radius: 5px) {
  203. @include css3-prefix('outline-radius', $radius);
  204. }
  205. /// Resize
  206. /// @param {*} $directoin [both] - Direction
  207. /// @require {mixin} css3-prefix
  208. @mixin resize($direction: both) {
  209. @include css3-prefix('resize', $direction);
  210. }
  211. /// Rotate
  212. ///
  213. /// CSS Matrix Rotation Calculator http://www.boogdesign.com/examples/transforms/matrix-calculator.html
  214. /// @param {Double} $deg [0] - Degree
  215. /// @param {Double} $m11 [0] - M11
  216. /// @param {Double} $m12 [0] - M12
  217. /// @param {Double} $m21 [0] - M21
  218. /// @param {Double} $m22 [0] - M22
  219. /// @require {mixin} css3-prefix
  220. @mixin rotate($deg: 0, $m11: 0, $m12: 0, $m21: 0, $m22: 0) {
  221. @include css3-prefix('transform', rotate($deg + deg));
  222. filter: progid:DXImageTransform.Microsoft.Matrix(
  223. M11=#{$m11}, M12=#{$m12}, M21=#{$m21}, M22=#{$m22}, sizingMethod='auto expand');
  224. zoom: 1;
  225. }
  226. /// Text Shadow
  227. /// @param {Size} $x [2px] - X
  228. /// @param {Size} $y [2px] - Y
  229. /// @param {Size} $blur [2px] - Blur
  230. /// @param {Color} $color [rgba(0,0,0,.4)] - Color
  231. @mixin text-shadow($x: 2px, $y: 2px, $blur: 5px, $color: rgba(0,0,0,.4)) {
  232. text-shadow: $x $y $blur $color;
  233. }
  234. /// Transform
  235. /// @param {List} $params - Params
  236. /// @require {mixin} css3-prefix
  237. @mixin transform($params) {
  238. @include css3-prefix('transform', $params);
  239. }
  240. /// Transform-Origin
  241. /// @param {List} $params - Params
  242. /// @require {mixin} css3-prefix
  243. @mixin transform-origin($params) {
  244. @include css3-prefix('transform-origin', $params);
  245. }
  246. // Transform-Style
  247. /// @param {List} $params - Params
  248. /// @require {mixin} css3-prefix
  249. @mixin transform-style($style: preserve-3d) {
  250. @include css3-prefix('transform-style', $style);
  251. }
  252. /// Transition
  253. /// @param {List} $properties - Properties
  254. /// @require {mixin} css3-prefix
  255. @mixin transition($properties...) {
  256. @if length($properties) >= 1 {
  257. @include css3-prefix('transition', $properties);
  258. }
  259. @else {
  260. @include css3-prefix('transition', "all 0.2s ease-in-out 0s");
  261. }
  262. }
  263. /// Triple Borders
  264. /// @param {Color} $colorOne [#3C3C3C] - Color One
  265. /// @param {Color} $colorTwo [#999999] - Color Two
  266. /// @param {Color} $colorThree [#000000] - Color Three
  267. /// @param {Size} $radius [0] - Radius
  268. /// @require {mixin} border-radius
  269. /// @require {mixin} css3-prefix
  270. @mixin triple-borders($colorOne: #3C3C3C, $colorTwo: #999999, $colorThree: #000000, $radius: 0) {
  271. border: 1px solid $colorOne;
  272. @include border-radius($radius);
  273. @include css3-prefix('box-shadow', "0 0 0 1px #{$colorTwo}, 0 0 0 2px #{$colorThree}");
  274. }
  275. /// Keyframes
  276. /// @param {*} $animation-name - Animation name
  277. /// @content [Animation css]
  278. @mixin keyframes($animation-name) {
  279. @-webkit-keyframes #{$animation-name} {
  280. @content;
  281. }
  282. @-moz-keyframes #{$animation-name} {
  283. @content;
  284. }
  285. @-ms-keyframes #{$animation-name} {
  286. @content;
  287. }
  288. @-o-keyframes #{$animation-name} {
  289. @content;
  290. }
  291. @keyframes #{$animation-name} {
  292. @content;
  293. }
  294. }
  295. /// Animation
  296. /// @param {*} $str - name duration timing-function delay iteration-count direction fill-mode play-state ([http://www.w3schools.com/cssref/css3_pr_animation.asp](http://www.w3schools.com/cssref/css3_pr_animation.asp))
  297. /// @require {mixin} css3-prefix
  298. @mixin animation($str) {
  299. @include css3-prefix('animation', $str);
  300. }
  301. @mixin text-overflow() {
  302. overflow: hidden;
  303. text-overflow: ellipsis;
  304. white-space: nowrap;
  305. }