mixins.scss 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. // Responsive image
  2. //
  3. // Keep images from scaling beyond the width of their parents.
  4. @mixin blur($blur) {
  5. -webkit-filter: blur($blur);
  6. -moz-filter: blur($blur);
  7. -o-filter: blur($blur);
  8. -ms-filter: blur($blur);
  9. filter: blur($blur);
  10. }
  11. @mixin img-responsive($display: block) {
  12. display: $display;
  13. max-width: 100%; // Part 1: Set a maximum relative to the parent
  14. height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
  15. }
  16. // Box sizing
  17. @mixin box-sizing($boxmodel) {
  18. -webkit-box-sizing: $boxmodel;
  19. -moz-box-sizing: $boxmodel;
  20. box-sizing: $boxmodel;
  21. }
  22. // User select
  23. // For selecting text on the page
  24. @mixin user-select($select) {
  25. -webkit-user-select: $select;
  26. -moz-user-select: $select;
  27. -ms-user-select: $select; // IE10+
  28. -o-user-select: $select;
  29. user-select: $select;
  30. }
  31. // Drop shadows
  32. //
  33. // Note: Deprecated `.box-shadow()` as of v3.1.0 since all of Bootstrap's
  34. // supported browsers that have box shadow capabilities now support the
  35. // standard `box-shadow` property.
  36. @mixin box-shadow($shadow...) {
  37. -webkit-box-shadow: $shadow; // iOS <4.3 & Android <4.1
  38. box-shadow: $shadow;
  39. }
  40. // Placeholder text
  41. @mixin placeholder($color: rgba(136,136,136,0.5)) {
  42. &:-moz-placeholder { color: $color; } // Firefox 4-18
  43. &::-moz-placeholder { color: $color; // Firefox 19+
  44. opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
  45. &:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
  46. &::-webkit-input-placeholder { color: $color; } // Safari and Chrome
  47. // &:hover {
  48. // &:-moz-placeholder { color: #aaa; } // Firefox 4-18
  49. // &::-moz-placeholder { color: #aaa; // Firefox 19+
  50. // opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
  51. // &:-ms-input-placeholder { color: #aaa; } // Internet Explorer 10+
  52. // &::-webkit-input-placeholder { color: #aaa; } // Safari and Chrome
  53. // }
  54. }
  55. // Placeholder text
  56. @mixin placeholder_inverted($color: $blue-lighter) {
  57. &:-moz-placeholder { color: $color; } // Firefox 4-18
  58. &::-moz-placeholder { color: $color; // Firefox 19+
  59. opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
  60. &:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
  61. &::-webkit-input-placeholder { color: $color; } // Safari and Chrome
  62. &:focus {
  63. &:-moz-placeholder { color: white; } // Firefox 4-18
  64. &::-moz-placeholder { color: white; // Firefox 19+
  65. opacity: 1; } // See https://github.com/twbs/bootstrap/pull/11526
  66. &:-ms-input-placeholder { color: white; } // Internet Explorer 10+
  67. &::-webkit-input-placeholder { color: white; } // Safari and Chrome
  68. }
  69. }
  70. @mixin input-focus($color: #aaa) {
  71. $color-rgba: rgba(red($color), green($color), blue($color), .6);
  72. &:focus {
  73. outline: 0;
  74. // @include box-shadow(inset 0 0 3px rgba(255,255,255,.075), 0 0 3px $color-rgba);
  75. }
  76. }
  77. // Transitions
  78. @mixin transition($transition...) {
  79. -webkit-transition: $transition;
  80. transition: $transition;
  81. }
  82. @mixin transition-property($transition-property...) {
  83. -webkit-transition-property: $transition-property;
  84. transition-property: $transition-property;
  85. }
  86. @mixin transition-delay($transition-delay) {
  87. -webkit-transition-delay: $transition-delay;
  88. transition-delay: $transition-delay;
  89. }
  90. @mixin transition-duration($transition-duration...) {
  91. -webkit-transition-duration: $transition-duration;
  92. transition-duration: $transition-duration;
  93. }
  94. @mixin transition-transform($transition...) {
  95. -webkit-transition: -webkit-transform $transition;
  96. -moz-transition: -moz-transform $transition;
  97. -o-transition: -o-transform $transition;
  98. transition: transform $transition;
  99. }
  100. // Transformations
  101. @mixin rotate($degrees) {
  102. -webkit-transform: rotate($degrees);
  103. -ms-transform: rotate($degrees); // IE9 only
  104. transform: rotate($degrees);
  105. }
  106. @mixin scale($ratio, $ratio-y...) {
  107. -webkit-transform: scale($ratio, $ratio-y);
  108. -ms-transform: scale($ratio, $ratio-y); // IE9 only
  109. transform: scale($ratio, $ratio-y);
  110. }
  111. @mixin translate($x, $y) {
  112. -webkit-transform: translate($x, $y);
  113. -ms-transform: translate($x, $y); // IE9 only
  114. transform: translate($x, $y);
  115. }
  116. @mixin translateX($x) {
  117. -webkit-transform: translateX($x);
  118. -ms-transform: translateX($x); // IE9 only
  119. transform: translateX($x);
  120. }
  121. @mixin translateY($y) {
  122. -webkit-transform: translateY($y);
  123. -ms-transform: translateY($y); // IE9 only
  124. transform: translateY($y);
  125. }
  126. @mixin skew($x, $y) {
  127. -webkit-transform: skew($x, $y);
  128. -ms-transform: skewX($x) skewY($y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+
  129. transform: skew($x, $y);
  130. }
  131. @mixin translate3d($x, $y, $z) {
  132. -webkit-transform: translate3d($x, $y, $z);
  133. transform: translate3d($x, $y, $z);
  134. }
  135. @mixin rotateX($degrees) {
  136. -webkit-transform: rotateX($degrees);
  137. -ms-transform: rotateX($degrees); // IE9 only
  138. transform: rotateX($degrees);
  139. }
  140. @mixin rotateY($degrees) {
  141. -webkit-transform: rotateY($degrees);
  142. -ms-transform: rotateY($degrees); // IE9 only
  143. transform: rotateY($degrees);
  144. }
  145. @mixin perspective($perspective) {
  146. -webkit-perspective: $perspective;
  147. -moz-perspective: $perspective;
  148. perspective: $perspective;
  149. }
  150. @mixin perspective-origin($perspective) {
  151. -webkit-perspective-origin: $perspective;
  152. -moz-perspective-origin: $perspective;
  153. perspective-origin: $perspective;
  154. }
  155. @mixin transform-origin($origin) {
  156. -webkit-transform-origin: $origin;
  157. -moz-transform-origin: $origin;
  158. -ms-transform-origin: $origin; // IE9 only
  159. transform-origin: $origin;
  160. }
  161. // Animations
  162. @mixin animation($animation) {
  163. -webkit-animation: $animation;
  164. animation: $animation;
  165. }
  166. @mixin animation-name($name) {
  167. -webkit-animation-name: $name;
  168. animation-name: $name;
  169. }
  170. @mixin animation-duration($duration) {
  171. -webkit-animation-duration: $duration;
  172. animation-duration: $duration;
  173. }
  174. @mixin animation-timing-function($timing-function) {
  175. -webkit-animation-timing-function: $timing-function;
  176. animation-timing-function: $timing-function;
  177. }
  178. @mixin animation-delay($delay) {
  179. -webkit-animation-delay: $delay;
  180. animation-delay: $delay;
  181. }
  182. @mixin animation-iteration-count($iteration-count) {
  183. -webkit-animation-iteration-count: $iteration-count;
  184. animation-iteration-count: $iteration-count;
  185. }
  186. @mixin animation-direction($direction) {
  187. -webkit-animation-direction: $direction;
  188. animation-direction: $direction;
  189. }
  190. @mixin animation-fill-mode($fill-mode) {
  191. -webkit-animation-fill-mode: $fill-mode;
  192. animation-fill-mode: $fill-mode;
  193. }
  194. // Backface visibility
  195. // Prevent browsers from flickering when using CSS 3D transforms.
  196. // Default value is `visible`, but can be changed to `hidden`
  197. @mixin backface-visibility($visibility){
  198. -webkit-backface-visibility: $visibility;
  199. -moz-backface-visibility: $visibility;
  200. backface-visibility: $visibility;
  201. }
  202. // Opacity
  203. @mixin opacity($opacity) {
  204. opacity: $opacity;
  205. // IE8 filter
  206. $opacity-ie: ($opacity * 100);
  207. filter: #{alpha(opacity=$opacity-ie)};
  208. }
  209. // Clearfix
  210. // Source: http://nicolasgallagher.com/micro-clearfix-hack/
  211. //
  212. // For modern browsers
  213. // 1. The space content is one way to avoid an Opera bug when the
  214. // contenteditable attribute is included anywhere else in the document.
  215. // Otherwise it causes space to appear at the top and bottom of elements
  216. // that are clearfixed.
  217. // 2. The use of `table` rather than `block` is only necessary if using
  218. // `:before` to contain the top-margins of child elements.
  219. @mixin clearfix() {
  220. &:before,
  221. &:after {
  222. content: " "; // 1
  223. display: table; // 2
  224. }
  225. &:after {
  226. clear: both;
  227. }
  228. }
  229. // WebKit-style focus
  230. @mixin tab-focus() {
  231. // Default
  232. outline: thin dotted;
  233. // WebKit
  234. outline: 5px auto #298041;
  235. outline-offset: -2px;
  236. }
  237. @mixin icon-xxs {
  238. font-size: 9px;
  239. height: 16px;
  240. width: 16px;
  241. line-height: 16px;
  242. &:after,
  243. &:before {
  244. height: 16px;
  245. width: 16px;
  246. line-height: 12px;
  247. }
  248. }
  249. @mixin icon {
  250. font-size: 20px;
  251. height: 60px;
  252. width: 60px;
  253. display: inline-block;
  254. font-family: 'icon';
  255. text-align: center;
  256. font-style: normal;
  257. font-weight: normal;
  258. vertical-align: middle;
  259. -webkit-font-smoothing: antialiased;
  260. -moz-osx-font-smoothing: grayscale;
  261. @include transition(all 0s 0s ease-in-out);
  262. &:after,
  263. &:before {
  264. @include backface-visibility(hidden);
  265. position: absolute;
  266. height: 60px;
  267. width: 60px;
  268. line-height: 60px;
  269. text-align: center;
  270. left: 0px;
  271. top: 0px;
  272. }
  273. &:hover {
  274. text-decoration: none;
  275. }
  276. }
  277. @mixin icon-xs {
  278. font-size: 9px;
  279. height: 24px;
  280. width: 24px;
  281. line-height: 24px;
  282. &:after,
  283. &:before {
  284. height: 24px;
  285. width: 24px;
  286. line-height: 24px;
  287. }
  288. }
  289. @mixin icon-sm {
  290. font-size: 14px;
  291. height: 32px;
  292. width: 32px;
  293. line-height: 32px;
  294. &:after,
  295. &:before {
  296. height: 32px;
  297. width: 32px;
  298. line-height: 32px;
  299. }
  300. }
  301. @mixin icon-md {
  302. font-size: 16px;
  303. height: 44px;
  304. width: 44px;
  305. line-height: 43px;
  306. &:after,
  307. &:before {
  308. height: 44px;
  309. width: 44px;
  310. line-height: 43px;
  311. }
  312. }
  313. @mixin icon-xl {
  314. font-size: 28px;
  315. height: 80px;
  316. width: 80px;
  317. line-height: 80px;
  318. &:after,
  319. &:before {
  320. height: 80px;
  321. width: 80px;
  322. line-height: 75px;
  323. }
  324. }
  325. @mixin icon-xxl {
  326. font-size: 50px;
  327. height: 140px;
  328. width: 140px;
  329. line-height: 130px;
  330. &:after,
  331. &:before {
  332. height: 140px;
  333. width: 140px;
  334. line-height: 130px;
  335. }
  336. }