buttons.less 3.18 KB
Newer Older
1
2
3
// BUTTON STYLES
// -------------

4
.btn {
5
  // Set text color
6
7
  &.primary,
  &.primary:hover,
8
9
10
11
12
13
  &.danger,
  &.danger:hover,
  &.success,
  &.success:hover,
  &.info,
  &.info:hover {
14
    text-shadow: 0 -1px 0 rgba(0,0,0,.25);
15
16
    color: @white
  }
17
18
19
  &.primary {
    .buttonBackground(@primaryButtonBackground, spin(@primaryButtonBackground, 15));
  }
20
  // Danger and error appear as red
21
  &.danger {
22
    .buttonBackground(#ee5f5b, #c43c35);
23
24
25
  }
  // Success appears as green
  &.success {
26
    .buttonBackground(#62c462, #57a957);
27
28
29
  }
  // Info appears as a neutral blue
  &.info {
30
31
32
33
34
35
36
37
38
    .buttonBackground(#5bc0de, #339bb9);
  }
}

.buttonBackground(@startColor, @endColor) {
  // gradientBar will set the background to a pleasing blend of these, to support IE<=9
  .gradientBar(@startColor, @endColor);

  // in these cases the gradient won't cover the background, so we override
39
40
41
42
43
  &:hover, &:active, &.active, &.disabled {
    background-color: @endColor;
  }

  &[disabled] {
44
45
46
47
48
49
50
    background-color: @endColor;
  }

  &:active,
  &.active {
    // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
    background-color: darken(@endColor, 10%) e("\9");
51
52
53
54
55
56
57
  }
}

// Base .btn styles
.btn {
  // Button Base
  display: inline-block;
58
  padding: 5px 10px 6px;
59
60
  font-size: @baseFontSize;
  line-height: normal;
61
  color: @grayDark;
62
  text-shadow: 0 1px 1px rgba(255,255,255,.75);
63
  #gradient > .vertical-three-colors(@white, @white, 25%, darken(@white, 10%)); // Don't use .gradientbar() here since it does a three-color gradient
64
65
66
67
68
69
70
71
72
73
  border: 1px solid #ccc;
  border-bottom-color: #bbb;
  .border-radius(4px);
  @shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
  .box-shadow(@shadow);
  cursor: pointer;

  &:hover {
    color: @grayDark;
    text-decoration: none;
74
    background-color: darken(@white, 10%);
75
    background-position: 0 -15px;
76
77
78
79

    // transition is only when going to hover, otherwise the background
    // behind the gradient (there for IE<=9 fallback) gets mismatched
    .transition(background-position .1s linear);
80
81
82
83
84
85
86
87
88
89
  }

  // Focus state for keyboard and accessibility
  &:focus {
    outline: 1px dotted #666;
  }

  // Active and Disabled states
  &.active,
  &:active {
90
91
    background-image: none;
    @shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
92
    .box-shadow(@shadow);
93
94
    background-color: darken(@white, 10%);
    background-color: darken(@white, 15%) e("\9");
95
96
97
98
  }
  &.disabled {
    cursor: default;
    background-image: none;
99
    background-color: darken(@white, 10%);
100
101
102
103
104
105
106
107
    .opacity(65);
    .box-shadow(none);
  }
  &[disabled] {
    // disabled pseudo can't be included with .disabled
    // def because IE8 and below will drop it ;_;
    cursor: default;
    background-image: none;
108
    background-color: darken(@white, 10%);
109
110
111
112
113
114
115
116
117
    .opacity(65);
    .box-shadow(none);
  }

  // Button Sizes
  &.large {
    padding: 9px 14px 9px;
    font-size: @baseFontSize + 2px;
    line-height: normal;
118
    .border-radius(5px);
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  }
  &.small {
    padding: 7px 9px 7px;
    font-size: @baseFontSize - 2px;
  }
}

// Help Firefox not be a jerk about adding extra padding to buttons
button.btn,
input[type=submit].btn {
  &::-moz-focus-inner {
  	padding: 0;
  	border: 0;
  }
133
}