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

5
// Button carets
Mark Otto's avatar
Mark Otto committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//
// Match the button text color to the arrow/caret for indicating dropdown-ness.

.caret {
  .btn-default & {
    border-top-color: @btn-default-color;
  }
  .btn-primary &,
  .btn-success &,
  .btn-warning &,
  .btn-danger &,
  .btn-info & {
    border-top-color: #fff;
  }
20
}
21
22
.dropup {
  & .btn-default .caret {
Mark Otto's avatar
Mark Otto committed
23
24
    border-bottom-color: @btn-default-color;
  }
25
26
27
28
29
  .btn-primary,
  .btn-success,
  .btn-warning,
  .btn-danger,
  .btn-info {
30
31
32
   .caret {
      border-bottom-color: #fff;
    }
Mark Otto's avatar
Mark Otto committed
33
  }
34
}
35
36

// Make the div behave like a button
37
38
.btn-group,
.btn-group-vertical {
39
  position: relative;
40
  display: inline-block;
41
  vertical-align: middle; // match .btn alignment given font-size hack above
Mark Otto's avatar
Mark Otto committed
42
  > .btn {
43
    position: relative;
Mark Otto's avatar
Mark Otto committed
44
    float: left;
45
46
    // Bring the "active" button to the front
    &:hover,
47
    &:focus,
48
49
    &:active,
    &.active {
50
51
      z-index: 2;
    }
52
53
54
55
    &:focus {
      // Remove focus outline when dropdown JS adds it after closing the menu
      outline: none;
    }
Mark Otto's avatar
Mark Otto committed
56
  }
57
58
}

59
// Prevent double borders when buttons are next to each other
Mark Otto's avatar
derp    
Mark Otto committed
60
61
62
63
64
65
66
.btn-group {
  .btn + .btn,
  .btn + .btn-group,
  .btn-group + .btn,
  .btn-group + .btn-group {
    margin-left: -1px;
  }
67
68
}

69
// Optional: Group multiple button groups together for a toolbar
70
.btn-toolbar {
71
  .clearfix();
72

Mark Otto's avatar
Mark Otto committed
73
74
75
76
  .btn-group {
    float: left;
  }
  // Space out series of button groups
liuyl's avatar
liuyl committed
77
78
79
80
81
82
  > .btn,
  > .btn-group {
    + .btn,
    + .btn-group {
      margin-left: 5px;
    }
83
  }
84
85
}

86
.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
87
  border-radius: 0;
88
}
89

90
// 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
91
.btn-group > .btn:first-child {
92
  margin-left: 0;
93
94
95
  &:not(:last-child):not(.dropdown-toggle) {
    .border-right-radius(0);
  }
96
}
97
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
98
99
100
.btn-group > .btn:last-child:not(:first-child),
.btn-group > .dropdown-toggle:not(:first-child) {
  .border-left-radius(0);
101
102
}

103
104
105
106
// Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
.btn-group > .btn-group {
  float: left;
}
107
.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
108
109
  border-radius: 0;
}
110
111
112
113
114
.btn-group > .btn-group:first-child {
  > .btn:last-child,
  > .dropdown-toggle {
    .border-right-radius(0);
  }
115
}
116
117
.btn-group > .btn-group:last-child > .btn:first-child {
  .border-left-radius(0);
118
119
}

120
121
122
123
124
125
126
// On active and open, don't show outline
.btn-group .dropdown-toggle:active,
.btn-group.open .dropdown-toggle {
  outline: 0;
}


127
128
129
130
131
132
133
134
// Sizing
//
// Remix the default button sizing classes into new ones for easier manipulation.

.btn-group-xs > .btn { .btn-xs(); }
.btn-group-sm > .btn { .btn-sm(); }
.btn-group-lg > .btn { .btn-lg(); }

135
136
137
138
139

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

// Give the line between buttons some depth
140
.btn-group > .btn + .dropdown-toggle {
141
142
  padding-left: 8px;
  padding-right: 8px;
143
}
144
.btn-group > .btn-lg + .dropdown-toggle {
145
146
  padding-left: 12px;
  padding-right: 12px;
147
}
148

149
150
151
152
153
// The clickable button for toggling the menu
// Remove the gradient and set the same inset shadow as the :active state
.btn-group.open .dropdown-toggle {
  .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
}
154

Mark Otto's avatar
Mark Otto committed
155

156
157
158
159
// Reposition the caret
.btn .caret {
  margin-left: 0;
}
160
// Carets in other button sizes
161
.btn-lg .caret {
162
  border-width: @caret-width-large @caret-width-large 0;
liuyl's avatar
liuyl committed
163
  border-bottom-width: 0;
164
165
}
// Upside down carets for .dropup
166
.dropup .btn-lg .caret {
167
  border-width: 0 @caret-width-large @caret-width-large;
168
}
169

170

171
172
173
// Vertical button groups
// ----------------------

Mark Otto's avatar
derp    
Mark Otto committed
174
.btn-group-vertical {
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  > .btn,
  > .btn-group {
    display: block;
    float: none;
    width: 100%;
    max-width: 100%;
  }

  // Clear floats so dropdown menus can be properly placed
  > .btn-group {
    .clearfix();
    > .btn {
      float: none;
    }
  }

  > .btn + .btn,
  > .btn + .btn-group,
  > .btn-group + .btn,
  > .btn-group + .btn-group {
195
    margin-top: -1px;
Mark Otto's avatar
derp    
Mark Otto committed
196
    margin-left: 0;
197
198
  }
}
Mark Otto's avatar
derp    
Mark Otto committed
199
200

.btn-group-vertical > .btn {
201
202
203
  &:not(:first-child):not(:last-child) {
    border-radius: 0;
  }
liuyl's avatar
liuyl committed
204
  &:first-child:not(:last-child) {
Mark Otto's avatar
derp    
Mark Otto committed
205
    border-top-right-radius: @border-radius-base;
206
207
    .border-bottom-radius(0);
  }
liuyl's avatar
liuyl committed
208
  &:last-child:not(:first-child) {
Mark Otto's avatar
derp    
Mark Otto committed
209
    border-bottom-left-radius: @border-radius-base;
210
211
    .border-top-radius(0);
  }
212
}
Mark Otto's avatar
derp    
Mark Otto committed
213
214
215
216
217
218
219
220
221
222
223
224
225
.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  border-radius: 0;
}
.btn-group-vertical > .btn-group:first-child {
  > .btn:last-child,
  > .dropdown-toggle {
    .border-bottom-radius(0);
  }
}
.btn-group-vertical > .btn-group:last-child > .btn:first-child {
  .border-top-radius(0);
}

226
227
228
229
230
231
232
233


// Justified button groups
// ----------------------

.btn-group-justified {
  display: table;
  width: 100%;
liuyl's avatar
liuyl committed
234
  table-layout: fixed;
235
  border-collapse: separate;
236
237
238
239
240
241
  .btn {
    float: none;
    display: table-cell;
    width: 1%;
  }
}
242
243
244


// Checkbox and radio options
245
246
[data-toggle="buttons"] > .btn > input[type="radio"],
[data-toggle="buttons"] > .btn > input[type="checkbox"] {
247
248
  display: none;
}