static/less/button-groups.less
author stetrabby <info@trabucchi.de>
Fri, 20 Dec 2013 22:30:44 +0100
changeset 53 3416f82943ea
permissions -rwxr-xr-x
less initial added
info@53
     1
//
info@53
     2
// Button groups
info@53
     3
// --------------------------------------------------
info@53
     4
info@53
     5
// Make the div behave like a button
info@53
     6
.btn-group,
info@53
     7
.btn-group-vertical {
info@53
     8
  position: relative;
info@53
     9
  display: inline-block;
info@53
    10
  vertical-align: middle; // match .btn alignment given font-size hack above
info@53
    11
  > .btn {
info@53
    12
    position: relative;
info@53
    13
    float: left;
info@53
    14
    // Bring the "active" button to the front
info@53
    15
    &:hover,
info@53
    16
    &:focus,
info@53
    17
    &:active,
info@53
    18
    &.active {
info@53
    19
      z-index: 2;
info@53
    20
    }
info@53
    21
    &:focus {
info@53
    22
      // Remove focus outline when dropdown JS adds it after closing the menu
info@53
    23
      outline: none;
info@53
    24
    }
info@53
    25
  }
info@53
    26
}
info@53
    27
info@53
    28
// Prevent double borders when buttons are next to each other
info@53
    29
.btn-group {
info@53
    30
  .btn + .btn,
info@53
    31
  .btn + .btn-group,
info@53
    32
  .btn-group + .btn,
info@53
    33
  .btn-group + .btn-group {
info@53
    34
    margin-left: -1px;
info@53
    35
  }
info@53
    36
}
info@53
    37
info@53
    38
// Optional: Group multiple button groups together for a toolbar
info@53
    39
.btn-toolbar {
info@53
    40
  .clearfix();
info@53
    41
info@53
    42
  .btn-group {
info@53
    43
    float: left;
info@53
    44
  }
info@53
    45
  // Space out series of button groups
info@53
    46
  > .btn,
info@53
    47
  > .btn-group {
info@53
    48
    + .btn,
info@53
    49
    + .btn-group {
info@53
    50
      margin-left: 5px;
info@53
    51
    }
info@53
    52
  }
info@53
    53
}
info@53
    54
info@53
    55
.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
info@53
    56
  border-radius: 0;
info@53
    57
}
info@53
    58
info@53
    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
info@53
    60
.btn-group > .btn:first-child {
info@53
    61
  margin-left: 0;
info@53
    62
  &:not(:last-child):not(.dropdown-toggle) {
info@53
    63
    .border-right-radius(0);
info@53
    64
  }
info@53
    65
}
info@53
    66
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
info@53
    67
.btn-group > .btn:last-child:not(:first-child),
info@53
    68
.btn-group > .dropdown-toggle:not(:first-child) {
info@53
    69
  .border-left-radius(0);
info@53
    70
}
info@53
    71
info@53
    72
// Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
info@53
    73
.btn-group > .btn-group {
info@53
    74
  float: left;
info@53
    75
}
info@53
    76
.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
info@53
    77
  border-radius: 0;
info@53
    78
}
info@53
    79
.btn-group > .btn-group:first-child {
info@53
    80
  > .btn:last-child,
info@53
    81
  > .dropdown-toggle {
info@53
    82
    .border-right-radius(0);
info@53
    83
  }
info@53
    84
}
info@53
    85
.btn-group > .btn-group:last-child > .btn:first-child {
info@53
    86
  .border-left-radius(0);
info@53
    87
}
info@53
    88
info@53
    89
// On active and open, don't show outline
info@53
    90
.btn-group .dropdown-toggle:active,
info@53
    91
.btn-group.open .dropdown-toggle {
info@53
    92
  outline: 0;
info@53
    93
}
info@53
    94
info@53
    95
info@53
    96
// Sizing
info@53
    97
//
info@53
    98
// Remix the default button sizing classes into new ones for easier manipulation.
info@53
    99
info@53
   100
.btn-group-xs > .btn { .btn-xs(); }
info@53
   101
.btn-group-sm > .btn { .btn-sm(); }
info@53
   102
.btn-group-lg > .btn { .btn-lg(); }
info@53
   103
info@53
   104
info@53
   105
// Split button dropdowns
info@53
   106
// ----------------------
info@53
   107
info@53
   108
// Give the line between buttons some depth
info@53
   109
.btn-group > .btn + .dropdown-toggle {
info@53
   110
  padding-left: 8px;
info@53
   111
  padding-right: 8px;
info@53
   112
}
info@53
   113
.btn-group > .btn-lg + .dropdown-toggle {
info@53
   114
  padding-left: 12px;
info@53
   115
  padding-right: 12px;
info@53
   116
}
info@53
   117
info@53
   118
// The clickable button for toggling the menu
info@53
   119
// Remove the gradient and set the same inset shadow as the :active state
info@53
   120
.btn-group.open .dropdown-toggle {
info@53
   121
  .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
info@53
   122
info@53
   123
  // Show no shadow for `.btn-link` since it has no other button styles.
info@53
   124
  &.btn-link {
info@53
   125
    .box-shadow(none);
info@53
   126
  }
info@53
   127
}
info@53
   128
info@53
   129
info@53
   130
// Reposition the caret
info@53
   131
.btn .caret {
info@53
   132
  margin-left: 0;
info@53
   133
}
info@53
   134
// Carets in other button sizes
info@53
   135
.btn-lg .caret {
info@53
   136
  border-width: @caret-width-large @caret-width-large 0;
info@53
   137
  border-bottom-width: 0;
info@53
   138
}
info@53
   139
// Upside down carets for .dropup
info@53
   140
.dropup .btn-lg .caret {
info@53
   141
  border-width: 0 @caret-width-large @caret-width-large;
info@53
   142
}
info@53
   143
info@53
   144
info@53
   145
// Vertical button groups
info@53
   146
// ----------------------
info@53
   147
info@53
   148
.btn-group-vertical {
info@53
   149
  > .btn,
info@53
   150
  > .btn-group,
info@53
   151
  > .btn-group > .btn {
info@53
   152
    display: block;
info@53
   153
    float: none;
info@53
   154
    width: 100%;
info@53
   155
    max-width: 100%;
info@53
   156
  }
info@53
   157
info@53
   158
  // Clear floats so dropdown menus can be properly placed
info@53
   159
  > .btn-group {
info@53
   160
    .clearfix();
info@53
   161
    > .btn {
info@53
   162
      float: none;
info@53
   163
    }
info@53
   164
  }
info@53
   165
info@53
   166
  > .btn + .btn,
info@53
   167
  > .btn + .btn-group,
info@53
   168
  > .btn-group + .btn,
info@53
   169
  > .btn-group + .btn-group {
info@53
   170
    margin-top: -1px;
info@53
   171
    margin-left: 0;
info@53
   172
  }
info@53
   173
}
info@53
   174
info@53
   175
.btn-group-vertical > .btn {
info@53
   176
  &:not(:first-child):not(:last-child) {
info@53
   177
    border-radius: 0;
info@53
   178
  }
info@53
   179
  &:first-child:not(:last-child) {
info@53
   180
    border-top-right-radius: @border-radius-base;
info@53
   181
    .border-bottom-radius(0);
info@53
   182
  }
info@53
   183
  &:last-child:not(:first-child) {
info@53
   184
    border-bottom-left-radius: @border-radius-base;
info@53
   185
    .border-top-radius(0);
info@53
   186
  }
info@53
   187
}
info@53
   188
.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
info@53
   189
  border-radius: 0;
info@53
   190
}
info@53
   191
.btn-group-vertical > .btn-group:first-child {
info@53
   192
  > .btn:last-child,
info@53
   193
  > .dropdown-toggle {
info@53
   194
    .border-bottom-radius(0);
info@53
   195
  }
info@53
   196
}
info@53
   197
.btn-group-vertical > .btn-group:last-child > .btn:first-child {
info@53
   198
  .border-top-radius(0);
info@53
   199
}
info@53
   200
info@53
   201
info@53
   202
info@53
   203
// Justified button groups
info@53
   204
// ----------------------
info@53
   205
info@53
   206
.btn-group-justified {
info@53
   207
  display: table;
info@53
   208
  width: 100%;
info@53
   209
  table-layout: fixed;
info@53
   210
  border-collapse: separate;
info@53
   211
  > .btn,
info@53
   212
  > .btn-group {
info@53
   213
    float: none;
info@53
   214
    display: table-cell;
info@53
   215
    width: 1%;
info@53
   216
  }
info@53
   217
  > .btn-group .btn {
info@53
   218
    width: 100%;
info@53
   219
  }
info@53
   220
}
info@53
   221
info@53
   222
info@53
   223
// Checkbox and radio options
info@53
   224
[data-toggle="buttons"] > .btn > input[type="radio"],
info@53
   225
[data-toggle="buttons"] > .btn > input[type="checkbox"] {
info@53
   226
  display: none;
info@53
   227
}
Impressum Datenschutzerklärung