mixins.less 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. @rounded-corners {
  2. border-radius: 10px;
  3. }
  4. .bold {
  5. @font-size: 20px;
  6. font-size: @font-size;
  7. font-weight: bold;
  8. }
  9. body #window {
  10. @rounded-corners;
  11. .bold;
  12. line-height: @font-size * 1.5;
  13. }
  14. #bundle {
  15. .button {
  16. display: block;
  17. border: 1px solid black;
  18. background-color: grey;
  19. &:hover { background-color: white }
  20. }
  21. }
  22. #header a {
  23. color: orange;
  24. #bundle > .button; // mixin the button class
  25. }
  26. div {
  27. @abstract {
  28. hello: world;
  29. b {
  30. color: blue;
  31. }
  32. }
  33. @abstract > b;
  34. @abstract;
  35. }
  36. @poop {
  37. big: baby;
  38. }
  39. body {
  40. div;
  41. }
  42. // not using > to list mixins
  43. .hello {
  44. .world {
  45. color: blue;
  46. }
  47. }
  48. .foobar {
  49. .hello .world;
  50. }
  51. .butter {
  52. .this .one .isnt .found;
  53. }
  54. // arguments
  55. .spam(@something: 100, @dad: land) {
  56. @wow: 23434;
  57. foo: @arguments;
  58. bar: @arguments;
  59. }
  60. .eggs {
  61. .spam(1px, 2px);
  62. .spam();
  63. }
  64. .first(@one, @two, @three, @four: cool) {
  65. cool: @arguments;
  66. }
  67. #hello {
  68. .first(one, two, three);
  69. }
  70. #hello-important {
  71. .first(one, two, three) !important;
  72. }
  73. .rad(@name) {
  74. cool: @arguments;
  75. }
  76. #world {
  77. @hello: "world";
  78. .rad("@{hello}");
  79. }
  80. .second(@x, @y:skip, @z: me) {
  81. things: @arguments;
  82. }
  83. #another {
  84. .second(red, blue, green);
  85. .second(red blue green);
  86. }
  87. .another(@x, @y:skip, @z:me) {
  88. .cool {
  89. color: @arguments;
  90. }
  91. }
  92. #day {
  93. .another(one,two, three);
  94. .another(one two three);
  95. }
  96. .to-be-important() {
  97. color: red;
  98. @color: red;
  99. height: 20px;
  100. pre {
  101. color: @color;
  102. }
  103. }
  104. .mix-suffix {
  105. .to-be-important() !important;
  106. }
  107. #search-all {
  108. .red() {
  109. color:#f00 !important;
  110. }
  111. }
  112. #search-all {
  113. .green() {
  114. color: #0f0 !important;
  115. }
  116. }
  117. .search-test {
  118. #search-all > .red();
  119. #search-all > .green();
  120. }