mixins.less 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. //============================================================
  2. //
  3. // LESS CSS3 Mixins
  4. //
  5. // @description CSS3 mixins for projects using LESS
  6. // @see http://lesscss.org/
  7. // @version 2.00
  8. //
  9. // @author Matthew Wagerfield
  10. // @see http://matthew.wagerfield.com
  11. // @see http://twitter.com/mwagerfield
  12. //
  13. // ---------- INDEX ----------
  14. //
  15. // Display:
  16. // @mixin display-box
  17. // @mixin box-orient
  18. // @mixin box-pack
  19. // @mixin box-align
  20. // @mixin box-flex
  21. // @mixin box-sizing
  22. // @mixin user-select
  23. // @mixin appearance
  24. //
  25. // Decoration:
  26. // @mixin border-radius
  27. // @mixin box-shadow
  28. // @mixin text-shadow
  29. // @mixin linear-gradient
  30. // @mixin radial-gradient
  31. //
  32. // Transformation:
  33. // @mixin transform
  34. // @mixin transform-origin
  35. // @mixin transform-style
  36. // @mixin perspective
  37. // @mixin perspective-origin
  38. // @mixin backface-visibility
  39. // @mixin matrix
  40. // @mixin translate
  41. // @mixin scale
  42. // @mixin rotate
  43. // @mixin skew
  44. //
  45. // Animation:
  46. // @mixin transition
  47. // @mixin easing
  48. //
  49. //============================================================
  50. //============================================================
  51. //
  52. // display-box
  53. //
  54. // @see http://www.w3.org/TR/css3-flexbox/
  55. // @see http://www.html5rocks.com/en/tutorials/flexbox/quick/
  56. //
  57. //============================================================
  58. .display-box(...) {
  59. display: -webkit-box;
  60. display: -moz-box;
  61. display: -ms-box;
  62. display: -o-box;
  63. display: box;
  64. }
  65. //============================================================
  66. //
  67. // box-orient
  68. //
  69. // @param value : horizontal |
  70. // vertical |
  71. // inherit
  72. //
  73. // @see http://www.w3.org/TR/css3-flexbox/
  74. // @see http://www.html5rocks.com/en/tutorials/flexbox/quick/
  75. //
  76. //============================================================
  77. .box-orient(...) {
  78. .display-box();
  79. -webkit-box-orient: @arguments;
  80. -moz-box-orient: @arguments;
  81. -ms-box-orient: @arguments;
  82. -o-box-orient: @arguments;
  83. box-orient: @arguments;
  84. }
  85. //============================================================
  86. //
  87. // box-pack
  88. //
  89. // @param value : start |
  90. // end |
  91. // center |
  92. // justify
  93. //
  94. // @see http://www.w3.org/TR/css3-flexbox/
  95. // @see http://www.html5rocks.com/en/tutorials/flexbox/quick/
  96. //
  97. //============================================================
  98. .box-pack(...) {
  99. .display-box();
  100. -webkit-box-pack: @arguments;
  101. -moz-box-pack: @arguments;
  102. -ms-box-pack: @arguments;
  103. -o-box-pack: @arguments;
  104. box-pack: @arguments;
  105. }
  106. //============================================================
  107. //
  108. // box-align
  109. //
  110. // @param value : start |
  111. // end |
  112. // center |
  113. // baseline |
  114. // stretch
  115. //
  116. // @see http://www.w3.org/TR/css3-flexbox/
  117. // @see http://www.html5rocks.com/en/tutorials/flexbox/quick/
  118. //
  119. //============================================================
  120. .box-align(...) {
  121. .display-box();
  122. -webkit-box-align: @arguments;
  123. -moz-box-align: @arguments;
  124. -ms-box-align: @arguments;
  125. -o-box-align: @arguments;
  126. box-align: @arguments;
  127. }
  128. //============================================================
  129. //
  130. // box-flex
  131. //
  132. // @param value : 0 | Integer
  133. //
  134. // @see http://www.w3.org/TR/css3-flexbox/
  135. // @see http://www.html5rocks.com/en/tutorials/flexbox/quick/
  136. //
  137. //============================================================
  138. .box-flex(...) {
  139. .display-box();
  140. -webkit-box-flex: @arguments;
  141. -moz-box-flex: @arguments;
  142. -ms-box-flex: @arguments;
  143. -o-box-flex: @arguments;
  144. box-flex: @arguments;
  145. }
  146. //============================================================
  147. //
  148. // box-sizing
  149. //
  150. // @param value : content-box |
  151. // padding-box |
  152. // border-box |
  153. // inherit
  154. //
  155. // @see http://www.w3.org/TR/css3-ui/#box-sizing
  156. //
  157. //============================================================
  158. .box-sizing(...) {
  159. -webkit-box-sizing: @arguments;
  160. -moz-box-sizing: @arguments;
  161. box-sizing: @arguments;
  162. }
  163. //============================================================
  164. //
  165. // user-select
  166. //
  167. // @param value : none |
  168. // text |
  169. // toggle |
  170. // element |
  171. // elements |
  172. // all |
  173. // inherit
  174. //
  175. // @see http://www.w3.org/TR/2000/WD-css3-userint-20000216#user-select
  176. //
  177. //============================================================
  178. .user-select(...) {
  179. -webkit-touch-callout: @arguments;
  180. -webkit-user-select: @arguments;
  181. -moz-user-select: @arguments;
  182. -ms-user-select: @arguments;
  183. -o-user-select: @arguments;
  184. user-select: @arguments;
  185. }
  186. //============================================================
  187. //
  188. // appearance
  189. //
  190. // @param value : button |
  191. // push-button |
  192. // hyperlink |
  193. // radio-button |
  194. // checkbox |
  195. // pop-up-menu |
  196. // list-menu |
  197. // radio-group |
  198. // checkbox-group |
  199. // field |
  200. // password |
  201. // normal |
  202. // inherit |
  203. // none
  204. //
  205. // @see http://www.w3.org/TR/css3-ui/#appearance
  206. // @see http://www.cssportal.com/css-properties/appearance.htm
  207. // @see https://developer.mozilla.org/en/CSS/-moz-appearance
  208. //
  209. //============================================================
  210. .appearance(...) {
  211. -webkit-appearance: @arguments;
  212. -moz-appearance: @arguments;
  213. -ms-appearance: @arguments;
  214. -o-appearance: @arguments;
  215. appearance: @arguments;
  216. }
  217. //============================================================
  218. //
  219. // border-radius
  220. //
  221. // @param top-left-radius : px, em, %
  222. // @param top-right-radius : px, em, %
  223. // @param bottom-right-radius : px, em, %
  224. // @param bottom-left-radius : px, em, %
  225. //
  226. // @see http://www.w3.org/TR/css3-background/#border-radius
  227. //
  228. //============================================================
  229. .border-radius(...) {
  230. -webkit-border-radius: @arguments;
  231. -moz-border-radius: @arguments;
  232. border-radius: @arguments;
  233. -webkit-background-clip: padding-box;
  234. -moz-background-clip: padding;
  235. background-clip: padding-box;
  236. }
  237. //============================================================
  238. //
  239. // box-shadow
  240. //
  241. // @param colour : #000, rgba, hsla
  242. // @param horizontal-offset : px, em
  243. // @param vertical-offset : px, em
  244. // @param blur-radius : px, em
  245. // @param spread-distance : px, em
  246. // @param inset : inset
  247. //
  248. // @see http://www.w3.org/TR/css3-background/#box-shadow
  249. //
  250. //============================================================
  251. .box-shadow(...) {
  252. -webkit-box-shadow: @arguments;
  253. -moz-box-shadow: @arguments;
  254. box-shadow: @arguments;
  255. }
  256. //============================================================
  257. //
  258. // text-shadow
  259. //
  260. // @param colour : #000, rgba, hsla
  261. // @param horizontal-offset : px, em
  262. // @param vertical-offset : px, em
  263. // @param blur-radius : px, em
  264. //
  265. // @see http://www.w3.org/TR/css3-text/#text-shadow
  266. //
  267. //============================================================
  268. .text-shadow(...) {
  269. text-shadow: @arguments;
  270. }
  271. //============================================================
  272. //
  273. // linear-gradient
  274. //
  275. // @param angle : top, left, 90deg
  276. // @param colourA : #000 0%, red 0%
  277. // @param colourB : #000 50%, red 50%
  278. // @param colourC : #000 100%, red 100%
  279. //
  280. // @example .linear-gradient(top, ~',crimson 0%', ~',black 100%');
  281. //
  282. // @see http://dev.w3.org/csswg/css3-images/#linear-gradients
  283. //
  284. //============================================================
  285. .linear-gradient(...) {
  286. background-image: -webkit-linear-gradient(@arguments);
  287. background-image: -moz-linear-gradient(@arguments);
  288. background-image: -ms-linear-gradient(@arguments);
  289. background-image: -o-linear-gradient(@arguments);
  290. background-image: linear-gradient(@arguments);
  291. }
  292. //============================================================
  293. //
  294. // radial-gradient
  295. //
  296. // @param location : left top, 50% 50%
  297. // @param shape : circle, ellipse, 100% 75%
  298. // @param colourA : #000 0%, red 0%
  299. // @param colourB : #000 50%, red 50%
  300. // @param colourC : #000 100%, red 100%
  301. //
  302. // @example .radial-gradient(~'50% 50%,', circle, ~',crimson 0%', ~',black 100%');
  303. //
  304. // @see http://dev.w3.org/csswg/css3-images/#radial-gradients
  305. //
  306. //============================================================
  307. .radial-gradient(...) {
  308. background-image: -webkit-radial-gradient(@arguments);
  309. background-image: -moz-radial-gradient(@arguments);
  310. background-image: -ms-radial-gradient(@arguments);
  311. background-image: -o-radial-gradient(@arguments);
  312. background-image: radial-gradient(@arguments);
  313. }
  314. //============================================================
  315. //
  316. // transform
  317. //
  318. // @param functions : matrix()
  319. // : translate()
  320. // : scale()
  321. // : rotate()
  322. // : skew()
  323. //
  324. // @see http://www.w3.org/TR/css3-2d-transforms/
  325. //
  326. //============================================================
  327. .transform(...) {
  328. -webkit-transform: @arguments;
  329. -moz-transform: @arguments;
  330. -ms-transform: @arguments;
  331. -o-transform: @arguments;
  332. transform: @arguments;
  333. }
  334. //============================================================
  335. //
  336. // transform-origin
  337. //
  338. // @param value : left |
  339. // center |
  340. // right |
  341. // px |
  342. // em |
  343. // %;
  344. //
  345. // @see http://www.w3.org/TR/css3-3d-transforms/#transform-origin-property
  346. //
  347. //============================================================
  348. .transform-origin(...) {
  349. -webkit-transform-origin: @arguments;
  350. -moz-transform-origin: @arguments;
  351. -ms-transform-origin: @arguments;
  352. -o-transform-origin: @arguments;
  353. transform-origin: @arguments;
  354. }
  355. //============================================================
  356. //
  357. // transform-style
  358. //
  359. // @param value : preserve-3d | flat
  360. //
  361. // @see http://www.w3.org/TR/css3-3d-transforms/#transform-style-property
  362. //
  363. //============================================================
  364. .transform-style(...) {
  365. -webkit-transform-style: @arguments;
  366. -moz-transform-style: @arguments;
  367. -ms-transform-style: @arguments;
  368. -o-transform-style: @arguments;
  369. transform-style: @arguments;
  370. }
  371. //============================================================
  372. //
  373. // perspective
  374. //
  375. // @param value : none | 0, 1, 100, 1000, etc
  376. //
  377. // @see http://www.w3.org/TR/css3-3d-transforms/#perspective-property
  378. //
  379. //============================================================
  380. .perspective(...) {
  381. -webkit-perspective: @arguments;
  382. -moz-perspective: @arguments;
  383. -ms-perspective: @arguments;
  384. -o-perspective: @arguments;
  385. perspective: @arguments;
  386. }
  387. //============================================================
  388. //
  389. // perspective-origin
  390. //
  391. // @param value : left |
  392. // center |
  393. // right |
  394. // px |
  395. // em |
  396. // %
  397. //
  398. // @see http://www.w3.org/TR/css3-3d-transforms/#perspective-origin-property
  399. //
  400. //============================================================
  401. .perspective-origin(...) {
  402. -webkit-perspective-origin: @arguments;
  403. -moz-perspective-origin: @arguments;
  404. -ms-perspective-origin: @arguments;
  405. -o-perspective-origin: @arguments;
  406. perspective-origin: @arguments;
  407. }
  408. //============================================================
  409. //
  410. // backface-visibility
  411. //
  412. // @param value : visible | hidden
  413. //
  414. // @see http://www.w3.org/TR/css3-3d-transforms/#backface-visibility-property
  415. //
  416. //============================================================
  417. .backface-visibility(...) {
  418. -webkit-backface-visibility: @arguments;
  419. -moz-backface-visibility: @arguments;
  420. -ms-backface-visibility: @arguments;
  421. -o-backface-visibility: @arguments;
  422. backface-visibility: @arguments;
  423. }
  424. //============================================================
  425. //
  426. // matrix
  427. //
  428. // @param a : Number
  429. // @param b : Number
  430. // @param c : Number
  431. // @param d : Number
  432. // @param e : Number
  433. // @param f : Number
  434. //
  435. // http://www.w3.org/TR/css3-3d-transforms/#transform-functions
  436. //
  437. //============================================================
  438. .matrix(...) {
  439. -webkit-transform: matrix(@arguments);
  440. -moz-transform: matrix(@arguments);
  441. -ms-transform: matrix(@arguments);
  442. -o-transform: matrix(@arguments);
  443. transform: matrix(@arguments);
  444. }
  445. //============================================================
  446. //
  447. // translate
  448. //
  449. // @param translate-x : px
  450. // @param translate-y : px
  451. //
  452. // http://www.w3.org/TR/css3-3d-transforms/#transform-functions
  453. //
  454. //============================================================
  455. .translate(...) {
  456. -webkit-transform: translate(@arguments);
  457. -moz-transform: translate(@arguments);
  458. -ms-transform: translate(@arguments);
  459. -o-transform: translate(@arguments);
  460. transform: translate(@arguments);
  461. }
  462. //============================================================
  463. //
  464. // scale
  465. //
  466. // @param scale-x : 0.5, 2, etc
  467. // @param scale-y : 0.5, 2, etc
  468. //
  469. // http://www.w3.org/TR/css3-3d-transforms/#transform-functions
  470. //
  471. //============================================================
  472. .scale(...) {
  473. -webkit-transform: scale(@arguments);
  474. -moz-transform: scale(@arguments);
  475. -ms-transform: scale(@arguments);
  476. -o-transform: scale(@arguments);
  477. transform: scale(@arguments);
  478. }
  479. //============================================================
  480. //
  481. // rotate
  482. //
  483. // @param angle : 0deg
  484. //
  485. // http://www.w3.org/TR/css3-3d-transforms/#transform-functions
  486. //
  487. //============================================================
  488. .rotate(...) {
  489. -webkit-transform: rotate(@arguments);
  490. -moz-transform: rotate(@arguments);
  491. -ms-transform: rotate(@arguments);
  492. -o-transform: rotate(@arguments);
  493. transform: rotate(@arguments);
  494. }
  495. //============================================================
  496. //
  497. // skew
  498. //
  499. // @param axis-x : 0deg
  500. // @param axis-y : 0deg
  501. //
  502. // http://www.w3.org/TR/css3-3d-transforms/#transform-functions
  503. //
  504. //============================================================
  505. .skew(...) {
  506. -webkit-transform: skew(@arguments);
  507. -moz-transform: skew(@arguments);
  508. -ms-transform: skew(@arguments);
  509. -o-transform: skew(@arguments);
  510. transform: skew(@arguments);
  511. }
  512. //============================================================
  513. //
  514. // transition
  515. //
  516. // @param properties : all, left, opacity, etc
  517. // @param duration : 1s, 1000ms
  518. // @param delay : 1s, 1000ms
  519. // @param easing : linear, ease-in-out, etc
  520. //
  521. // @see http://www.w3.org/TR/css3-transitions/
  522. //
  523. //============================================================
  524. .transition(...) {
  525. -webkit-transition: @arguments;
  526. -moz-transition: @arguments;
  527. -ms-transition: @arguments;
  528. -o-transition: @arguments;
  529. transition: @arguments;
  530. }
  531. //============================================================
  532. //
  533. // easing
  534. //
  535. // Thanks to Robert Penner for his sterling work on easing,
  536. // and to Matthew Lein for converting these functions into
  537. // approximated cubic-bezier functions. Respect.
  538. //
  539. // @see http://robertpenner.com/
  540. // @see http://matthewlein.com/ceaser/
  541. //
  542. //============================================================
  543. // Cubic
  544. @easeInCubic : cubic-bezier(0.550, 0.055, 0.675, 0.190);
  545. @easeOutCubic : cubic-bezier(0.215, 0.610, 0.355, 1.000);
  546. @easeInOutCubic : cubic-bezier(0.645, 0.045, 0.355, 1.000);
  547. // Circ
  548. @easeInCirc : cubic-bezier(0.600, 0.040, 0.980, 0.335);
  549. @easeOutCirc : cubic-bezier(0.075, 0.820, 0.165, 1.000);
  550. @easeInOutCirc : cubic-bezier(0.785, 0.135, 0.150, 0.860);
  551. // Expo
  552. @easeInExpo : cubic-bezier(0.950, 0.050, 0.795, 0.035);
  553. @easeOutExpo : cubic-bezier(0.190, 1.000, 0.220, 1.000);
  554. @easeInOutExpo : cubic-bezier(1.000, 0.000, 0.000, 1.000);
  555. // Quad
  556. @easeInQuad : cubic-bezier(0.550, 0.085, 0.680, 0.530);
  557. @easeOutQuad : cubic-bezier(0.250, 0.460, 0.450, 0.940);
  558. @easeInOutQuad : cubic-bezier(0.455, 0.030, 0.515, 0.955);
  559. // Quart
  560. @easeInQuart : cubic-bezier(0.895, 0.030, 0.685, 0.220);
  561. @easeOutQuart : cubic-bezier(0.165, 0.840, 0.440, 1.000);
  562. @easeInOutQuart : cubic-bezier(0.770, 0.000, 0.175, 1.000);
  563. // Quint
  564. @easeInQuint : cubic-bezier(0.755, 0.050, 0.855, 0.060);
  565. @easeOutQuint : cubic-bezier(0.230, 1.000, 0.320, 1.000);
  566. @easeInOutQuint : cubic-bezier(0.860, 0.000, 0.070, 1.000);
  567. // Sine
  568. @easeInSine : cubic-bezier(0.470, 0.000, 0.745, 0.715);
  569. @easeOutSine : cubic-bezier(0.390, 0.575, 0.565, 1.000);
  570. @easeInOutSine : cubic-bezier(0.445, 0.050, 0.550, 0.950);
  571. // Back
  572. @easeInBack : cubic-bezier(0.600, -0.280, 0.735, 0.045);
  573. @easeOutBack : cubic-bezier(0.175, 0.885, 0.320, 1.275);
  574. @easeInOutBack : cubic-bezier(0.680, -0.550, 0.265, 1.550);
  575. //============================================================
  576. //
  577. // Copyright (c) 2012 Matthew Wagerfield
  578. //
  579. // Permission is hereby granted, free of charge, to any
  580. // person obtaining a copy of this software and associated
  581. // documentation files (the "Software"), to deal in the
  582. // Software without restriction, including without limitation
  583. // the rights to use, copy, modify, merge, publish, distribute,
  584. // sublicense, and/or sell copies of the Software, and to
  585. // permit persons to whom the Software is furnished to do
  586. // so, subject to the following conditions:
  587. //
  588. // The above copyright notice and this permission notice
  589. // shall be included in all copies or substantial portions
  590. // of the Software.
  591. //
  592. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
  593. // OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  594. // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  595. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  596. // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  597. // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  598. // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  599. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  600. // OR OTHER DEALINGS IN THE SOFTWARE.
  601. //
  602. //============================================================