buttons.less 4.61 KB
Newer Older
1
2
3
//
// Buttons
// --------------------------------------------------
4

5
6

// Base styles
Mark Otto's avatar
Mark Otto committed
7
// --------------------------------------------------
8

Mark Otto's avatar
Mark Otto committed
9
// Core
10
11
.btn {
  display: inline-block;
12
  .ie7-inline-block();
13
  padding: 4px 14px;
14
  margin-bottom: 0; // For input.btn
15
16
17
  font-size: @baseFontSize;
  line-height: @baseLineHeight;
  *line-height: @baseLineHeight;
18
  text-align: center;
19
  vertical-align: middle;
Jacob Thornton's avatar
Jacob Thornton committed
20
  cursor: pointer;
21
  .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
22
  border: 1px solid @btnBorder;
Jacob Thornton's avatar
Jacob Thornton committed
23
  *border: 0; // Remove the border to prevent IE7's black border on input:focus
24
  border-bottom-color: darken(@btnBorder, 10%);
25
  .border-radius(4px);
Jacob Thornton's avatar
Jacob Thornton committed
26
  .ie7-restore-left-whitespace(); // Give IE7 some love
27
  .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
28

29
30
31
32
33
34
35
  // Hover state
  &:hover {
    color: @grayDark;
    text-decoration: none;
    background-color: darken(@white, 10%);
    *background-color: darken(@white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
    background-position: 0 -15px;
36

37
38
39
40
    // 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);
  }
41

42
43
44
45
  // Focus state for keyboard and accessibility
  &:focus {
    .tab-focus();
  }
46

47
48
49
50
51
52
53
54
55
  // Active state
  &.active,
  &:active {
    background-color: darken(@white, 10%);
    background-color: darken(@white, 15%) e("\9");
    background-image: none;
    outline: 0;
    .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
  }
56

57
58
59
60
61
62
63
64
65
  // Disabled state
  &.disabled,
  &[disabled] {
    cursor: default;
    background-color: darken(@white, 10%);
    background-image: none;
    .opacity(65);
    .box-shadow(none);
  }
66

Mark Otto's avatar
Mark Otto committed
67
68
69
}


70

Mark Otto's avatar
Mark Otto committed
71
72
73
74
// Button Sizes
// --------------------------------------------------

// Large
75
.btn-large {
Mark Otto's avatar
Mark Otto committed
76
77
78
79
80
  padding: 9px 14px;
  font-size: @baseFontSize + 2px;
  line-height: normal;
  .border-radius(5px);
}
81
.btn-large [class^="icon-"] {
82
  margin-top: 2px;
Mark Otto's avatar
Mark Otto committed
83
84
85
}

// Small
86
.btn-small {
87
  padding: 3px 9px;
Mark Otto's avatar
Mark Otto committed
88
89
90
  font-size: @baseFontSize - 2px;
  line-height: @baseLineHeight - 2px;
}
91
.btn-small [class^="icon-"] {
92
  margin-top: 0;
Mark Otto's avatar
Mark Otto committed
93
94
}

Mark Otto's avatar
Mark Otto committed
95
96
97
// Mini
.btn-mini {
  padding: 2px 6px;
98
  font-size: @baseFontSize - 3px;
99
  line-height: @baseLineHeight - 3px;
Mark Otto's avatar
Mark Otto committed
100
101
}

102
103
104
105
106
107
108
109
// Block button
.btn-block {
  display: block;
  width: 100%;
  padding-left: 0;
  padding-right: 0;
  .box-sizing(border-box);
}
Mark Otto's avatar
Mark Otto committed
110
111
112
.btn-block + .btn-block {
  margin-top: 5px;
}
113

Mark Otto's avatar
Mark Otto committed
114
115
116
117
118

// Alternate buttons
// --------------------------------------------------

// Provide *some* extra contrast for those who can get it
119
120
121
122
.btn-primary.active,
.btn-warning.active,
.btn-danger.active,
.btn-success.active,
Simon's avatar
Simon committed
123
.btn-info.active,
Mark Otto's avatar
Mark Otto committed
124
.btn-inverse.active {
Mark Otto's avatar
Mark Otto committed
125
126
127
128
129
  color: rgba(255,255,255,.75);
}

// Set the backgrounds
// -------------------------
130
.btn {
131
  // reset here as of 2.0.3 due to Recess property order
Mark Otto's avatar
Mark Otto committed
132
133
  border-color: #c5c5c5;
  border-color: rgba(0,0,0,.15) rgba(0,0,0,.15) rgba(0,0,0,.25);
134
}
135
.btn-primary {
136
  .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
137
}
Mark Otto's avatar
Mark Otto committed
138
// Warning appears are orange
139
.btn-warning {
140
  .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
141
142
}
// Danger and error appear as red
143
.btn-danger {
144
  .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
145
146
}
// Success appears as green
147
.btn-success {
148
  .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
149
150
}
// Info appears as a neutral blue
151
.btn-info {
152
  .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
Mark Otto's avatar
Mark Otto committed
153
}
154
155
// Inverse appears as dark gray
.btn-inverse {
156
  .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
Simon's avatar
Simon committed
157
}
Mark Otto's avatar
Mark Otto committed
158
159
160
161


// Cross-browser Jank
// --------------------------------------------------
162
163

button.btn,
164
input[type="submit"].btn {
Mark Otto's avatar
Mark Otto committed
165
166

  // Firefox 3.6 only I believe
167
  &::-moz-focus-inner {
168
    padding: 0;
Mark Otto's avatar
Mark Otto committed
169
    border: 0;
170
  }
171
172

  // IE7 has some default padding on button controls
173
174
175
  *padding-top: 3px;
  *padding-bottom: 3px;

176
  &.btn-large {
177
178
179
    *padding-top: 7px;
    *padding-bottom: 7px;
  }
180
  &.btn-small {
181
182
183
    *padding-top: 3px;
    *padding-bottom: 3px;
  }
Mark Otto's avatar
Mark Otto committed
184
185
186
187
  &.btn-mini {
    *padding-top: 1px;
    *padding-bottom: 1px;
  }
188
}
189
190
191
192
193
194


// Link buttons
// --------------------------------------------------

// Make a button look and behave like a link
195
196
.btn-link,
.btn-link:active {
197
198
  background-color: transparent;
  background-image: none;
199
  .box-shadow(none);
200
201
}
.btn-link {
202
203
204
  border-color: transparent;
  cursor: pointer;
  color: @linkColor;
205
  .border-radius(0);
206
207
208
209
210
211
}
.btn-link:hover {
  color: @linkColorHover;
  text-decoration: underline;
  background-color: transparent;
}