1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-19 11:51:23 +02:00

Clean up button group (#25073)

* Remove unnecessary float

- since parent btn-group is displayed as inline-flex, the child elements are placed left to right by default.

* Cleanup of reset rounded corners

- Remove `border-radius :0` since it is enough by each reset of left and right side
- A `.dropdown-toggle` selector should not be used for reset rounded corner since it does not have border-radius property. Instead use .dropdown-toggle as negation pseudo-class.
This commit is contained in:
ysds
2017-12-27 09:04:11 +09:00
committed by Mark Otto
parent 8c6011ab4f
commit c5209270ac

View File

@@ -44,46 +44,18 @@
} }
.btn-group { .btn-group {
> .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
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:first-child { > .btn:first-child {
margin-left: 0; margin-left: 0;
&:not(:last-child):not(.dropdown-toggle) {
@include border-right-radius(0);
}
} }
// Reset rounded corners
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu > .btn:not(:last-child):not(.dropdown-toggle),
// immediately after it > .btn-group:not(:last-child) > .btn {
> .btn:last-child:not(:first-child), @include border-right-radius(0);
> .dropdown-toggle:not(:first-child) {
@include border-left-radius(0);
} }
// Custom edits for including btn-groups within btn-groups (useful for including > .btn:not(:first-child),
// dropdown buttons within a btn-group) > .btn-group:not(:first-child) > .btn {
> .btn-group {
float: left;
}
> .btn-group:not(:first-child):not(:last-child) > .btn {
border-radius: 0;
}
> .btn-group:first-child:not(:last-child) {
> .btn:last-child,
> .dropdown-toggle {
@include border-right-radius(0);
}
}
> .btn-group:last-child:not(:first-child) > .btn:first-child {
@include border-left-radius(0); @include border-left-radius(0);
} }
} }
@@ -154,32 +126,14 @@
margin-left: 0; margin-left: 0;
} }
> .btn { // Reset rounded corners
&:not(:first-child):not(:last-child) { > .btn:not(:last-child):not(.dropdown-toggle),
border-radius: 0; > .btn-group:not(:last-child) > .btn {
} @include border-bottom-radius(0);
&:first-child:not(:last-child) {
@include border-bottom-radius(0);
}
&:last-child:not(:first-child) {
@include border-top-radius(0);
}
} }
> .btn-group:not(:first-child):not(:last-child) > .btn { > .btn:not(:first-child),
border-radius: 0; > .btn-group:not(:first-child) > .btn {
}
> .btn-group:first-child:not(:last-child) {
> .btn:last-child,
> .dropdown-toggle {
@include border-bottom-radius(0);
}
}
> .btn-group:last-child:not(:first-child) > .btn:first-child {
@include border-top-radius(0); @include border-top-radius(0);
} }
} }