buttons.less 4.62 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
  font-size: 13px;
  line-height: 20px;
Jacob Thornton's avatar
Jacob Thornton committed
17
  *line-height: 20px;
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-"] {
Mark Otto's avatar
Mark Otto committed
82
83
84
85
  margin-top: 1px;
}

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

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

102
103
104
105
106
107
108
109
110
// 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
111
112
113
114
115

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

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

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


// Cross-browser Jank
// --------------------------------------------------
159
160

button.btn,
161
input[type="submit"].btn {
Mark Otto's avatar
Mark Otto committed
162
163

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

  // IE7 has some default padding on button controls
  *padding-top: 2px;
  *padding-bottom: 2px;
172
  &.btn-large {
173
174
175
    *padding-top: 7px;
    *padding-bottom: 7px;
  }
176
  &.btn-small {
177
178
179
    *padding-top: 3px;
    *padding-bottom: 3px;
  }
Mark Otto's avatar
Mark Otto committed
180
181
182
183
  &.btn-mini {
    *padding-top: 1px;
    *padding-bottom: 1px;
  }
184
}
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208


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

// Make a button look and behave like a link
.btn-link {
  background-color: transparent;
  background-image: none;
  border-color: transparent;
  cursor: pointer;
  color: @linkColor;
  -webkit-border-radius: 0;
     -moz-border-radius: 0;
          border-radius: 0;
  -webkit-box-shadow: none;
     -moz-box-shadow: none;
          box-shadow: none;
}
.btn-link:hover {
  color: @linkColorHover;
  text-decoration: underline;
  background-color: transparent;
}