mixins.less 20 KB

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