Skip to content

Instantly share code, notes, and snippets.

@sherbrow
Created July 2, 2012 19:38
Show Gist options
  • Save sherbrow/3035209 to your computer and use it in GitHub Desktop.
Save sherbrow/3035209 to your computer and use it in GitHub Desktop.
Twitter-bootstrap add-on to create dropdowns in button groups (like http://jsfiddle.net/Sherbrow/3R3EV/6/ )
.dropdown-btn {
display: inline-block;
*display: inline;
/* IE7 inline-block hack */
*zoom: 1;
padding: 4px 10px 4px;
margin-bottom: 0;
font-size: 13px;
line-height: 18px;
*line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(top, #ffffff, #e6e6e6);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #e6e6e6;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
border: 1px solid #cccccc;
*border: 0;
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
*margin-left: .3em;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
}
.dropdown-btn:hover,
.dropdown-btn:active,
.dropdown-btn.active,
.dropdown-btn.disabled,
.dropdown-btn[disabled] {
background-color: #e6e6e6;
*background-color: #d9d9d9;
}
.dropdown-btn:active,
.dropdown-btn.active { background-color: #cccccc \9 }
.dropdown-btn:first-child { *margin-left: 0 }
.dropdown-btn:hover {
color: #333333;
text-decoration: none;
background-color: #e6e6e6;
*background-color: #d9d9d9;
/* Buttons in IE7 don't get borders, so darken on hover */
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-ms-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
.dropdown-btn:focus {
outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.dropdown-btn.active,
.dropdown-btn:active {
background-color: #e6e6e6;
background-color: #d9d9d9 \9;
background-image: none;
outline: 0;
-webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
}
.dropdown-btn.disabled,
.dropdown-btn[disabled] {
cursor: default;
background-color: #e6e6e6;
background-image: none;
opacity: 0.65;
filter: alpha(opacity=65);
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.dropdown-btn-large {
padding: 9px 14px;
font-size: 15px;
line-height: normal;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.dropdown-btn-large [class^="icon-"] { margin-top: 1px }
.dropdown-btn-small {
padding: 5px 9px;
font-size: 11px;
line-height: 16px;
}
.dropdown-btn-small [class^="icon-"] { margin-top: -1px }
.dropdown-btn-mini {
padding: 2px 6px;
font-size: 11px;
line-height: 14px;
}
.dropdown-btn-primary,
.dropdown-btn-primary:hover,
.dropdown-btn-warning,
.dropdown-btn-warning:hover,
.dropdown-btn-danger,
.dropdown-btn-danger:hover,
.dropdown-btn-success,
.dropdown-btn-success:hover,
.dropdown-btn-info,
.dropdown-btn-info:hover,
.dropdown-btn-inverse,
.dropdown-btn-inverse:hover {
color: #ffffff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.dropdown-btn-primary.active,
.dropdown-btn-warning.active,
.dropdown-btn-danger.active,
.dropdown-btn-success.active,
.dropdown-btn-info.active,
.dropdown-btn-inverse.active { color: rgba(255, 255, 255, 0.75) }
.dropdown-btn {
border-color: #ccc;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
.dropdown-btn-primary {
background-color: #0074cc;
background-image: -moz-linear-gradient(top, #0088cc, #0055cc);
background-image: -ms-linear-gradient(top, #0088cc, #0055cc);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0055cc));
background-image: -webkit-linear-gradient(top, #0088cc, #0055cc);
background-image: -o-linear-gradient(top, #0088cc, #0055cc);
background-image: linear-gradient(top, #0088cc, #0055cc);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0055cc', GradientType=0);
border-color: #0055cc #0055cc #003580;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #0055cc;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-primary:hover,
.dropdown-btn-primary:active,
.dropdown-btn-primary.active,
.dropdown-btn-primary.disabled,
.dropdown-btn-primary[disabled] {
background-color: #0055cc;
*background-color: #004ab3;
}
.dropdown-btn-primary:active,
.dropdown-btn-primary.active { background-color: #004099 \9 }
.dropdown-btn-warning {
background-color: #faa732;
background-image: -moz-linear-gradient(top, #fbb450, #f89406);
background-image: -ms-linear-gradient(top, #fbb450, #f89406);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
background-image: -o-linear-gradient(top, #fbb450, #f89406);
background-image: linear-gradient(top, #fbb450, #f89406);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);
border-color: #f89406 #f89406 #ad6704;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #f89406;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-warning:hover,
.dropdown-btn-warning:active,
.dropdown-btn-warning.active,
.dropdown-btn-warning.disabled,
.dropdown-btn-warning[disabled] {
background-color: #f89406;
*background-color: #df8505;
}
.dropdown-btn-warning:active,
.dropdown-btn-warning.active { background-color: #c67605 \9 }
.dropdown-btn-danger {
background-color: #da4f49;
background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
background-image: -ms-linear-gradient(top, #ee5f5b, #bd362f);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
background-image: linear-gradient(top, #ee5f5b, #bd362f);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#bd362f', GradientType=0);
border-color: #bd362f #bd362f #802420;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #bd362f;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-danger:hover,
.dropdown-btn-danger:active,
.dropdown-btn-danger.active,
.dropdown-btn-danger.disabled,
.dropdown-btn-danger[disabled] {
background-color: #bd362f;
*background-color: #a9302a;
}
.dropdown-btn-danger:active,
.dropdown-btn-danger.active { background-color: #942a25 \9 }
.dropdown-btn-success {
background-color: #5bb75b;
background-image: -moz-linear-gradient(top, #62c462, #51a351);
background-image: -ms-linear-gradient(top, #62c462, #51a351);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
background-image: -webkit-linear-gradient(top, #62c462, #51a351);
background-image: -o-linear-gradient(top, #62c462, #51a351);
background-image: linear-gradient(top, #62c462, #51a351);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0);
border-color: #51a351 #51a351 #387038;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #51a351;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-success:hover,
.dropdown-btn-success:active,
.dropdown-btn-success.active,
.dropdown-btn-success.disabled,
.dropdown-btn-success[disabled] {
background-color: #51a351;
*background-color: #499249;
}
.dropdown-btn-success:active,
.dropdown-btn-success.active { background-color: #408140 \9 }
.dropdown-btn-info {
background-color: #49afcd;
background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
background-image: -ms-linear-gradient(top, #5bc0de, #2f96b4);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
background-image: linear-gradient(top, #5bc0de, #2f96b4);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de', endColorstr='#2f96b4', GradientType=0);
border-color: #2f96b4 #2f96b4 #1f6377;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #2f96b4;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-info:hover,
.dropdown-btn-info:active,
.dropdown-btn-info.active,
.dropdown-btn-info.disabled,
.dropdown-btn-info[disabled] {
background-color: #2f96b4;
*background-color: #2a85a0;
}
.dropdown-btn-info:active,
.dropdown-btn-info.active { background-color: #24748c \9 }
.dropdown-btn-inverse {
background-color: #414141;
background-image: -moz-linear-gradient(top, #555555, #222222);
background-image: -ms-linear-gradient(top, #555555, #222222);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#555555), to(#222222));
background-image: -webkit-linear-gradient(top, #555555, #222222);
background-image: -o-linear-gradient(top, #555555, #222222);
background-image: linear-gradient(top, #555555, #222222);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#555555', endColorstr='#222222', GradientType=0);
border-color: #222222 #222222 #000000;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
*background-color: #222222;
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.dropdown-btn-inverse:hover,
.dropdown-btn-inverse:active,
.dropdown-btn-inverse.active,
.dropdown-btn-inverse.disabled,
.dropdown-btn-inverse[disabled] {
background-color: #222222;
*background-color: #151515;
}
.dropdown-btn-inverse:active,
.dropdown-btn-inverse.active { background-color: #080808 \9 }
button.dropdown-btn,
input[type="submit"].dropdown-btn {
*padding-top: 2px;
*padding-bottom: 2px;
}
button.dropdown-btn::-moz-focus-inner,
input[type="submit"].dropdown-btn::-moz-focus-inner {
padding: 0;
border: 0;
}
button.dropdown-btn.dropdown-btn-large,
input[type="submit"].dropdown-btn.dropdown-btn-large {
*padding-top: 7px;
*padding-bottom: 7px;
}
button.dropdown-btn.dropdown-btn-small,
input[type="submit"].dropdown-btn.dropdown-btn-small {
*padding-top: 3px;
*padding-bottom: 3px;
}
button.dropdown-btn.dropdown-btn-mini,
input[type="submit"].dropdown-btn.dropdown-btn-mini {
*padding-top: 1px;
*padding-bottom: 1px;
}
.btn-group {
position: relative;
*zoom: 1;
*margin-left: .3em;
}
.btn-group:before,
.btn-group:after {
display: table;
content: "";
}
.btn-group:after { clear: both }
.btn-group:first-child { *margin-left: 0 }
.btn-group + .btn-group { margin-left: 5px }
.dropdown-btn-toolbar {
margin-top: 9px;
margin-bottom: 9px;
}
.dropdown-btn-toolbar .btn-group {
display: inline-block;
*display: inline;
/* IE7 inline-block hack */
*zoom: 1;
}
.btn-group > .dropdown-btn {
position: relative;
float: left;
margin-left: -1px;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.btn-group > .dropdown-btn:first-child {
margin-left: 0;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-left-radius: 4px;
}
.btn-group > .dropdown-btn:last-child,
.btn-group > .dropdown-toggle {
-webkit-border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
border-bottom-right-radius: 4px;
}
.btn-group > .dropdown-btn.large:first-child {
margin-left: 0;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topleft: 6px;
border-top-left-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-moz-border-radius-bottomleft: 6px;
border-bottom-left-radius: 6px;
}
.btn-group > .dropdown-btn.large:last-child,
.btn-group > .large.dropdown-toggle {
-webkit-border-top-right-radius: 6px;
-moz-border-radius-topright: 6px;
border-top-right-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-moz-border-radius-bottomright: 6px;
border-bottom-right-radius: 6px;
}
.btn-group > .dropdown-btn:hover,
.btn-group > .dropdown-btn:focus,
.btn-group > .dropdown-btn:active,
.btn-group > .dropdown-btn.active { z-index: 2 }
.btn-group .dropdown-toggle:active,
.btn-group.open .dropdown-toggle { outline: 0 }
.btn-group > .dropdown-toggle {
padding-left: 8px;
padding-right: 8px;
-webkit-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);
-moz-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);
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);
*padding-top: 4px;
*padding-bottom: 4px;
}
.btn-group > .dropdown-btn-mini.dropdown-toggle {
padding-left: 5px;
padding-right: 5px;
}
.btn-group > .dropdown-btn-small.dropdown-toggle {
*padding-top: 4px;
*padding-bottom: 4px;
}
.btn-group > .dropdown-btn-large.dropdown-toggle {
padding-left: 12px;
padding-right: 12px;
}
.btn-group.open .dropdown-toggle {
background-image: none;
-webkit-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
box-shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
}
.btn-group.open .dropdown-btn.dropdown-toggle { background-color: #e6e6e6 }
.btn-group.open .dropdown-btn-primary.dropdown-toggle { background-color: #0055cc }
.btn-group.open .dropdown-btn-warning.dropdown-toggle { background-color: #f89406 }
.btn-group.open .dropdown-btn-danger.dropdown-toggle { background-color: #bd362f }
.btn-group.open .dropdown-btn-success.dropdown-toggle { background-color: #51a351 }
.btn-group.open .dropdown-btn-info.dropdown-toggle { background-color: #2f96b4 }
.btn-group.open .dropdown-btn-inverse.dropdown-toggle { background-color: #222222 }
.dropdown-btn .caret {
margin-top: 7px;
margin-left: 0;
}
.dropdown-btn:hover .caret,
.open.btn-group .caret {
opacity: 1;
filter: alpha(opacity=100);
}
.dropdown-btn-mini .caret { margin-top: 5px }
.dropdown-btn-small .caret { margin-top: 6px }
.dropdown-btn-large .caret {
margin-top: 6px;
border-left-width: 5px;
border-right-width: 5px;
border-top-width: 5px;
}
.dropup .dropdown-btn-large .caret {
border-bottom: 5px solid #000000;
border-top: 0;
}
.dropdown-btn-primary .caret,
.dropdown-btn-warning .caret,
.dropdown-btn-danger .caret,
.dropdown-btn-info .caret,
.dropdown-btn-success .caret,
.dropdown-btn-inverse .caret {
border-top-color: #ffffff;
border-bottom-color: #ffffff;
opacity: 0.75;
filter: alpha(opacity=75);
}
$('.dropdown-btn').on('click.dropdownbtn', function(e) {
e.stopPropagation();
e.preventDefault();
$(this).children('.dropdown-toggle').trigger('click.dropdown.data-api');
});
// DROPDOWN BUTTON STYLES
// -------------
// Base styles
// --------------------------------------------------
// Core
.dropdown-btn {
display: inline-block;
.ie7-inline-block();
padding: 4px 10px 4px;
margin-bottom: 0; // For input.dropdown-btn
font-size: @baseFontSize;
line-height: @baseLineHeight;
*line-height: 20px;
color: @grayDark;
text-align: center;
text-shadow: 0 1px 1px rgba(255,255,255,.75);
vertical-align: middle;
cursor: pointer;
.buttonBackground(@btnBackground, @btnBackgroundHighlight);
border: 1px solid @btnBorder;
*border: 0; // Remove the border to prevent IE7's black border on input:focus
border-bottom-color: darken(@btnBorder, 10%);
.border-radius(4px);
.ie7-restore-left-whitespace(); // Give IE7 some love
.box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
}
// Hover state
.dropdown-btn: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;
// 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);
}
// Focus state for keyboard and accessibility
.dropdown-btn:focus {
.tab-focus();
}
// Active state
.dropdown-btn.active,
.dropdown-btn: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)");
}
// Disabled state
.dropdown-btn.disabled,
.dropdown-btn[disabled] {
cursor: default;
background-color: darken(@white, 10%);
background-image: none;
.opacity(65);
.box-shadow(none);
}
// Button Sizes
// --------------------------------------------------
// Large
.dropdown-btn-large {
padding: 9px 14px;
font-size: @baseFontSize + 2px;
line-height: normal;
.border-radius(5px);
}
.dropdown-btn-large [class^="icon-"] {
margin-top: 1px;
}
// Small
.dropdown-btn-small {
padding: 5px 9px;
font-size: @baseFontSize - 2px;
line-height: @baseLineHeight - 2px;
}
.dropdown-btn-small [class^="icon-"] {
margin-top: -1px;
}
// Mini
.dropdown-btn-mini {
padding: 2px 6px;
font-size: @baseFontSize - 2px;
line-height: @baseLineHeight - 4px;
}
// Alternate buttons
// --------------------------------------------------
// Set text color
// -------------------------
.dropdown-btn-primary,
.dropdown-btn-primary:hover,
.dropdown-btn-warning,
.dropdown-btn-warning:hover,
.dropdown-btn-danger,
.dropdown-btn-danger:hover,
.dropdown-btn-success,
.dropdown-btn-success:hover,
.dropdown-btn-info,
.dropdown-btn-info:hover,
.dropdown-btn-inverse,
.dropdown-btn-inverse:hover {
color: @white;
text-shadow: 0 -1px 0 rgba(0,0,0,.25);
}
// Provide *some* extra contrast for those who can get it
.dropdown-btn-primary.active,
.dropdown-btn-warning.active,
.dropdown-btn-danger.active,
.dropdown-btn-success.active,
.dropdown-btn-info.active,
.dropdown-btn-inverse.active {
color: rgba(255,255,255,.75);
}
// Set the backgrounds
// -------------------------
.dropdown-btn {
// 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);
}
.dropdown-btn-primary {
.buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
}
// Warning appears are orange
.dropdown-btn-warning {
.buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
}
// Danger and error appear as red
.dropdown-btn-danger {
.buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
}
// Success appears as green
.dropdown-btn-success {
.buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
}
// Info appears as a neutral blue
.dropdown-btn-info {
.buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
}
// Inverse appears as dark gray
.dropdown-btn-inverse {
.buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
}
// Cross-browser Jank
// --------------------------------------------------
button.dropdown-btn,
input[type="submit"].dropdown-btn {
// Firefox 3.6 only I believe
&::-moz-focus-inner {
padding: 0;
border: 0;
}
// IE7 has some default padding on button controls
*padding-top: 2px;
*padding-bottom: 2px;
&.dropdown-btn-large {
*padding-top: 7px;
*padding-bottom: 7px;
}
&.dropdown-btn-small {
*padding-top: 3px;
*padding-bottom: 3px;
}
&.dropdown-btn-mini {
*padding-top: 1px;
*padding-bottom: 1px;
}
}
// DROPDOWN BUTTON GROUPS
// -------------
// Make the div behave like a button
.btn-group {
position: relative;
.clearfix(); // clears the floated buttons
.ie7-restore-left-whitespace();
}
// Space out series of button groups
.btn-group + .btn-group {
margin-left: 5px;
}
// Optional: Group multiple button groups together for a toolbar
.dropdown-btn-toolbar {
margin-top: @baseLineHeight / 2;
margin-bottom: @baseLineHeight / 2;
.btn-group {
display: inline-block;
.ie7-inline-block();
}
}
// Float them, remove border radius, then re-add to first and last elements
.btn-group > .dropdown-btn {
position: relative;
float: left;
margin-left: -1px;
.border-radius(0);
}
// 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
.btn-group > .dropdown-btn:first-child {
margin-left: 0;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-left-radius: 4px;
}
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
.btn-group > .dropdown-btn:last-child,
.btn-group > .dropdown-toggle {
-webkit-border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
border-bottom-right-radius: 4px;
}
// Reset corners for large buttons
.btn-group > .dropdown-btn.large:first-child {
margin-left: 0;
-webkit-border-top-left-radius: 6px;
-moz-border-radius-topleft: 6px;
border-top-left-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-moz-border-radius-bottomleft: 6px;
border-bottom-left-radius: 6px;
}
.btn-group > .dropdown-btn.large:last-child,
.btn-group > .large.dropdown-toggle {
-webkit-border-top-right-radius: 6px;
-moz-border-radius-topright: 6px;
border-top-right-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-moz-border-radius-bottomright: 6px;
border-bottom-right-radius: 6px;
}
// On hover/focus/active, bring the proper btn to front
.btn-group > .dropdown-btn:hover,
.btn-group > .dropdown-btn:focus,
.btn-group > .dropdown-btn:active,
.btn-group > .dropdown-btn.active {
z-index: 2;
}
// On active and open, don't show outline
.btn-group .dropdown-toggle:active,
.btn-group.open .dropdown-toggle {
outline: 0;
}
// Split button dropdowns
// ----------------------
// Give the line between buttons some depth
.btn-group > .dropdown-toggle {
padding-left: 8px;
padding-right: 8px;
.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)");
*padding-top: 4px;
*padding-bottom: 4px;
}
.btn-group > .dropdown-btn-mini.dropdown-toggle {
padding-left: 5px;
padding-right: 5px;
}
.btn-group > .dropdown-btn-small.dropdown-toggle {
*padding-top: 4px;
*padding-bottom: 4px;
}
.btn-group > .dropdown-btn-large.dropdown-toggle {
padding-left: 12px;
padding-right: 12px;
}
.btn-group.open {
// The clickable button for toggling the menu
// Remove the gradient and set the same inset shadow as the :active state
.dropdown-toggle {
background-image: none;
.box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
}
// Keep the hover's background when dropdown is open
.dropdown-btn.dropdown-toggle {
background-color: @btnBackgroundHighlight;
}
.dropdown-btn-primary.dropdown-toggle {
background-color: @btnPrimaryBackgroundHighlight;
}
.dropdown-btn-warning.dropdown-toggle {
background-color: @btnWarningBackgroundHighlight;
}
.dropdown-btn-danger.dropdown-toggle {
background-color: @btnDangerBackgroundHighlight;
}
.dropdown-btn-success.dropdown-toggle {
background-color: @btnSuccessBackgroundHighlight;
}
.dropdown-btn-info.dropdown-toggle {
background-color: @btnInfoBackgroundHighlight;
}
.dropdown-btn-inverse.dropdown-toggle {
background-color: @btnInverseBackgroundHighlight;
}
}
// Reposition the caret
.dropdown-btn .caret {
margin-top: 7px;
margin-left: 0;
}
.dropdown-btn:hover .caret,
.open.btn-group .caret {
.opacity(100);
}
// Carets in other button sizes
.dropdown-btn-mini .caret {
margin-top: 5px;
}
.dropdown-btn-small .caret {
margin-top: 6px;
}
.dropdown-btn-large .caret {
margin-top: 6px;
border-left-width: 5px;
border-right-width: 5px;
border-top-width: 5px;
}
// Upside down carets for .dropup
.dropup .dropdown-btn-large .caret {
border-bottom: 5px solid @black;
border-top: 0;
}
// Account for other colors
.dropdown-btn-primary,
.dropdown-btn-warning,
.dropdown-btn-danger,
.dropdown-btn-info,
.dropdown-btn-success,
.dropdown-btn-inverse {
.caret {
border-top-color: @white;
border-bottom-color: @white;
.opacity(75);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment