mixins.less 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. .vertical(@startColor: #555, @endColor: #333) {
  58. background-color: mix(@startColor, @endColor, 60%);
  59. background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
  60. background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
  61. background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
  62. background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
  63. background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
  64. background-repeat: repeat-x;
  65. filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor), argb(@endColor))); // IE9 and down
  66. }
  67. }
  68. .reset-filter() {
  69. filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
  70. }
  71. .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
  72. .gradientBar(@startColor, @endColor, @textColor, @textShadow);
  73. *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */
  74. .reset-filter(); // in these cases the gradient won't cover the background, so we override
  75. &:hover, &:focus, &:active, &.active, &.disabled, &[disabled] {
  76. color: @textColor;
  77. background-color: @endColor;
  78. *background-color: darken(@endColor, 5%);
  79. }
  80. // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
  81. &:active,
  82. &.active {
  83. background-color: darken(@endColor, 10%) e("\9");
  84. }
  85. }