mixins.scss 13 KB

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