mixins.less 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. .border-radius(@radius) {
  2. -webkit-border-radius: @radius;
  3. -moz-border-radius: @radius;
  4. border-radius: @radius;
  5. }
  6. .border-top-left-radius(@radius) {
  7. -webkit-border-top-left-radius: @radius;
  8. -moz-border-radius-topleft: @radius;
  9. border-top-left-radius: @radius;
  10. }
  11. .border-bottom-left-radius(@radius) {
  12. -webkit-border-bottom-left-radius: @radius;
  13. -moz-border-radius-bottomleft: @radius;
  14. border-bottom-left-radius: @radius;
  15. }
  16. .border-left-radius(@radius) {
  17. .border-top-left-radius(@radius);
  18. .border-bottom-left-radius(@radius);
  19. }
  20. // Transitions
  21. .transition(@transition) {
  22. -webkit-transition: @transition;
  23. -moz-transition: @transition;
  24. -o-transition: @transition;
  25. transition: @transition;
  26. }
  27. // Box sizing
  28. .box-sizing(@boxmodel) {
  29. -webkit-box-sizing: @boxmodel;
  30. -moz-box-sizing: @boxmodel;
  31. box-sizing: @boxmodel;
  32. }
  33. // User select
  34. // For selecting text on the page
  35. .user-select(@select) {
  36. -webkit-user-select: @select;
  37. -moz-user-select: @select;
  38. -ms-user-select: @select;
  39. -o-user-select: @select;
  40. user-select: @select;
  41. }
  42. // Opacity
  43. .opacity(@opacity) {
  44. opacity: @opacity / 100;
  45. filter: ~"alpha(opacity=@{opacity})";
  46. }
  47. // Gradient Bar Colors for buttons and alerts
  48. .gradientBar(@primaryColor, @secondaryColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
  49. color: @textColor;
  50. text-shadow: @textShadow;
  51. #gradient > .vertical(@primaryColor, @secondaryColor);
  52. border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);
  53. border-color: rgba(0, 0, 0, .1) rgba(0, 0, 0, .1) fadein(rgba(0, 0, 0, .1), 15%);
  54. }
  55. // Gradients
  56. #gradient {
  57. .horizontal(@startColor: #555, @endColor: #333) {
  58. background-color: @endColor;
  59. background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
  60. background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
  61. background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  62. background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
  63. background-image: linear-gradient(to right, @startColor, @endColor); // Standard, IE10
  64. background-repeat: repeat-x;
  65. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@startColor), argb(@endColor))); // IE9 and down
  66. }
  67. .vertical(@startColor: #555, @endColor: #333) {
  68. background-color: mix(@startColor, @endColor, 60%);
  69. background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
  70. background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
  71. background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  72. background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
  73. background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
  74. background-repeat: repeat-x;
  75. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor), argb(@endColor))); // IE9 and down
  76. }
  77. .directional(@startColor: #555, @endColor: #333, @deg: 45deg) {
  78. background-color: @endColor;
  79. background-repeat: repeat-x;
  80. background-image: -moz-linear-gradient(@deg, @startColor, @endColor); // FF 3.6+
  81. background-image: -webkit-linear-gradient(@deg, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  82. background-image: -o-linear-gradient(@deg, @startColor, @endColor); // Opera 11.10
  83. background-image: linear-gradient(@deg, @startColor, @endColor); // Standard, IE10
  84. }
  85. .horizontal-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
  86. background-color: mix(@midColor, @endColor, 80%);
  87. background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
  88. background-image: -webkit-linear-gradient(left, @startColor, @midColor @colorStop, @endColor);
  89. background-image: -moz-linear-gradient(left, @startColor, @midColor @colorStop, @endColor);
  90. background-image: -o-linear-gradient(left, @startColor, @midColor @colorStop, @endColor);
  91. background-image: linear-gradient(to right, @startColor, @midColor @colorStop, @endColor);
  92. background-repeat: no-repeat;
  93. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor), argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback
  94. }
  95. .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
  96. background-color: mix(@midColor, @endColor, 80%);
  97. background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
  98. background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor);
  99. background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor);
  100. background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor);
  101. background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor);
  102. background-repeat: no-repeat;
  103. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor), argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback
  104. }
  105. .radial(@innerColor: #555, @outerColor: #333) {
  106. background-color: @outerColor;
  107. background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@innerColor), to(@outerColor));
  108. background-image: -webkit-radial-gradient(circle, @innerColor, @outerColor);
  109. background-image: -moz-radial-gradient(circle, @innerColor, @outerColor);
  110. background-image: -o-radial-gradient(circle, @innerColor, @outerColor);
  111. background-repeat: no-repeat;
  112. }
  113. .striped(@color: #555, @angle: 45deg) {
  114. background-color: @color;
  115. background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)), color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent), to(transparent));
  116. background-image: -webkit-linear-gradient(@angle, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  117. background-image: -moz-linear-gradient(@angle, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  118. background-image: -o-linear-gradient(@angle, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  119. background-image: linear-gradient(@angle, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
  120. }
  121. }
  122. // Reset filters for IE
  123. .reset-filter() {
  124. filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
  125. }
  126. // COMPONENT MIXINS
  127. // --------------------------------------------------
  128. // Horizontal dividers
  129. // -------------------------
  130. // Dividers (basically an hr) within dropdowns and nav lists
  131. .nav-divider(@top: #e5e5e5, @bottom: @white) { // IE7 needs a set width since we gave a height. Restricting just
  132. // to IE7 to keep the 1px left/right space in other browsers.
  133. // It is unclear where IE is getting the extra space that we need
  134. // to negative-margin away, but so it goes.
  135. *width: 100%;
  136. height: 1px;
  137. margin: ((@baseLineHeight / 2) - 1) 1px; // 8px 1px
  138. *margin: -5px 0 5px;
  139. overflow: hidden;
  140. background-color: @top;
  141. border-bottom: 1px solid @bottom;
  142. }
  143. // Button backgrounds
  144. // ------------------
  145. .buttonBackground(@startColor, @endColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) { // gradientBar will set the background to a pleasing blend of these, to support IE<=9
  146. .gradientBar(@startColor, @endColor, @textColor, @textShadow);
  147. *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */
  148. .reset-filter(); // in these cases the gradient won't cover the background, so we override
  149. &:hover, &:focus, &:active, &.active, &.disabled, &[disabled] {
  150. color: @textColor;
  151. background-color: @endColor;
  152. *background-color: darken(@endColor, 5%);
  153. }
  154. // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
  155. &:active,
  156. &.active {
  157. background-color: darken(@endColor, 10%) e("\9");
  158. }
  159. }
  160. // Navbar vertical align
  161. // -------------------------
  162. // Vertically center elements in the navbar.
  163. // Example: an element has a height of 30px, so write out `.navbarVerticalAlign(30px);` to calculate the appropriate top margin.
  164. .navbarVerticalAlign(@elementHeight) {
  165. margin-top: (@navbarHeight - @elementHeight) / 2;
  166. }
  167. // Grid System
  168. // -----------
  169. // Centered container element
  170. .container-fixed() {
  171. margin-right: auto;
  172. margin-left: auto;
  173. .clearfix();
  174. }