button-groups.less 5.58 KB
Newer Older
1
2
3
//
// Button groups
// --------------------------------------------------
4

5
6
7
8

// Make the div behave like a button
.btn-group {
  position: relative;
9
10
  display: inline-block;
  .ie7-inline-block();
11
  font-size: 0; // remove as part 1 of font-size inline-block hack
12
  vertical-align: middle; // match .btn alignment given font-size hack above
13
  white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page)
14
  .ie7-restore-left-whitespace();
15
16
17
18
19
20
21
22
}

// Space out series of button groups
.btn-group + .btn-group {
  margin-left: 5px;
}

// Optional: Group multiple button groups together for a toolbar
23
.btn-toolbar {
24
  font-size: 0; // Hack to remove whitespace that results from using inline-block
25
26
  margin-top: @baseLineHeight / 2;
  margin-bottom: @baseLineHeight / 2;
27
28
29
  > .btn + .btn,
  > .btn-group + .btn,
  > .btn + .btn-group {
30
31
    margin-left: 5px;
  }
32
33
34
}

// Float them, remove border radius, then re-add to first and last elements
35
.btn-group > .btn {
36
37
38
  position: relative;
  .border-radius(0);
}
39
40
41
.btn-group > .btn + .btn {
  margin-left: -1px;
}
42
.btn-group > .btn,
43
44
.btn-group > .dropdown-menu,
.btn-group > .popover {
45
  font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack
46
}
47
48

// Reset fonts for other sizes
49
.btn-group > .btn-mini {
50
  font-size: @fontSizeMini;
51
}
52
.btn-group > .btn-small {
53
  font-size: @fontSizeSmall;
54
55
}
.btn-group > .btn-large {
56
  font-size: @fontSizeLarge;
57
58
}

59
// Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
60
.btn-group > .btn:first-child {
61
  margin-left: 0;
62
63
  .border-top-left-radius(@baseBorderRadius);
  .border-bottom-left-radius(@baseBorderRadius);
64
}
65
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
66
67
.btn-group > .btn:last-child,
.btn-group > .dropdown-toggle {
68
69
  .border-top-right-radius(@baseBorderRadius);
  .border-bottom-right-radius(@baseBorderRadius);
70
71
}
// Reset corners for large buttons
72
.btn-group > .btn.large:first-child {
73
  margin-left: 0;
74
75
  .border-top-left-radius(@borderRadiusLarge);
  .border-bottom-left-radius(@borderRadiusLarge);
76
}
77
78
.btn-group > .btn.large:last-child,
.btn-group > .large.dropdown-toggle {
79
80
  .border-top-right-radius(@borderRadiusLarge);
  .border-bottom-right-radius(@borderRadiusLarge);
81
82
}

83
// On hover/focus/active, bring the proper btn to front
84
85
86
87
.btn-group > .btn:hover,
.btn-group > .btn:focus,
.btn-group > .btn:active,
.btn-group > .btn.active {
88
89
  z-index: 2;
}
90

91
92
93
94
95
96
97
// On active and open, don't show outline
.btn-group .dropdown-toggle:active,
.btn-group.open .dropdown-toggle {
  outline: 0;
}


98
99
100
101
102

// Split button dropdowns
// ----------------------

// Give the line between buttons some depth
103
.btn-group > .btn + .dropdown-toggle {
104
105
  padding-left: 8px;
  padding-right: 8px;
106
  .box-shadow(~"inset 1px 0 0 rgba(255,255,255,.125), inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
107
108
  *padding-top: 5px;
  *padding-bottom: 5px;
109
}
110
.btn-group > .btn-mini + .dropdown-toggle {
111
112
  padding-left: 5px;
  padding-right: 5px;
113
114
  *padding-top: 2px;
  *padding-bottom: 2px;
Mark Otto's avatar
Mark Otto committed
115
}
116
.btn-group > .btn-small + .dropdown-toggle {
117
  *padding-top: 5px;
118
  *padding-bottom: 4px;
119
}
120
.btn-group > .btn-large + .dropdown-toggle {
121
122
  padding-left: 12px;
  padding-right: 12px;
123
124
  *padding-top: 7px;
  *padding-bottom: 7px;
125
}
126

127
128
.btn-group.open {

Mark Otto's avatar
Mark Otto committed
129
130
  // The clickable button for toggling the menu
  // Remove the gradient and set the same inset shadow as the :active state
131
132
  .dropdown-toggle {
    background-image: none;
133
    .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
134
  }
Mark Otto's avatar
Mark Otto committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

  // Keep the hover's background when dropdown is open
  .btn.dropdown-toggle {
    background-color: @btnBackgroundHighlight;
  }
  .btn-primary.dropdown-toggle {
    background-color: @btnPrimaryBackgroundHighlight;
  }
  .btn-warning.dropdown-toggle {
    background-color: @btnWarningBackgroundHighlight;
  }
  .btn-danger.dropdown-toggle {
    background-color: @btnDangerBackgroundHighlight;
  }
  .btn-success.dropdown-toggle {
    background-color: @btnSuccessBackgroundHighlight;
  }
  .btn-info.dropdown-toggle {
    background-color: @btnInfoBackgroundHighlight;
  }
  .btn-inverse.dropdown-toggle {
    background-color: @btnInverseBackgroundHighlight;
  }
158
159
}

Mark Otto's avatar
Mark Otto committed
160

161
162
// Reposition the caret
.btn .caret {
163
  margin-top: 8px;
164
165
  margin-left: 0;
}
166
// Carets in other button sizes
167
.btn-large .caret {
168
  margin-top: 6px;
169
170
}
.btn-large .caret {
171
172
173
174
  border-left-width:  5px;
  border-right-width: 5px;
  border-top-width:   5px;
}
175
176
177
178
.btn-mini .caret,
.btn-small .caret {
  margin-top: 8px;
}
179
180
// Upside down carets for .dropup
.dropup .btn-large .caret {
181
  border-bottom-width: 5px;
182
}
183

184

185

186
// Account for other colors
187
.btn-primary,
188
.btn-warning,
189
190
.btn-danger,
.btn-info,
Simon's avatar
Simon committed
191
.btn-success,
192
.btn-inverse {
193
  .caret {
194
    border-top-color: @white;
195
    border-bottom-color: @white;
196
197
198
  }
}

199
200
201
202
203
204
205


// Vertical button groups
// ----------------------

.btn-group-vertical {
  display: inline-block; // makes buttons only take up the width they need
Mark Otto's avatar
Mark Otto committed
206
  .ie7-inline-block();
207
}
208
.btn-group-vertical > .btn {
209
210
  display: block;
  float: none;
211
  max-width: 100%;
212
213
  .border-radius(0);
}
214
.btn-group-vertical > .btn + .btn {
215
  margin-left: 0;
216
217
  margin-top: -1px;
}
218
.btn-group-vertical > .btn:first-child {
219
  .border-radius(@baseBorderRadius @baseBorderRadius 0 0);
220
}
221
.btn-group-vertical > .btn:last-child {
222
  .border-radius(0 0 @baseBorderRadius @baseBorderRadius);
223
}
224
.btn-group-vertical > .btn-large:first-child {
225
  .border-radius(@borderRadiusLarge @borderRadiusLarge 0 0);
226
}
227
.btn-group-vertical > .btn-large:last-child {
228
  .border-radius(0 0 @borderRadiusLarge @borderRadiusLarge);
229
}