diff options
author | Mark Otto <markotto@twitter.com> | 2012-06-26 02:46:46 +0400 |
---|---|---|
committer | Mark Otto <markotto@twitter.com> | 2012-06-26 02:47:07 +0400 |
commit | 8c2db7d7d62d22183601364e7dcaee4a12b083ea (patch) | |
tree | 7c14e82e51ff0d3ec03fcb6205e088046c18b650 /less | |
parent | 78849cf52ef2eba9dd8df621985ac277b67dd23b (diff) |
prevent button group buttons from wrapping in tight spaces by removing floats and replacing with font-size: 0; inline-block hack
Diffstat (limited to 'less')
-rw-r--r-- | less/button-groups.less | 15 | ||||
-rw-r--r-- | less/tests/css-tests.html | 28 |
2 files changed, 41 insertions, 2 deletions
diff --git a/less/button-groups.less b/less/button-groups.less index e3c1de8adf..44f13a09a2 100644 --- a/less/button-groups.less +++ b/less/button-groups.less @@ -5,7 +5,8 @@ // Make the div behave like a button .btn-group { position: relative; - .clearfix(); // clears the floated buttons + font-size: 0; // remove as part 1 of font-size inline-block hack + white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page) .ie7-restore-left-whitespace(); } @@ -27,10 +28,20 @@ // Float them, remove border radius, then re-add to first and last elements .btn-group > .btn { position: relative; - float: left; margin-left: -1px; + font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack .border-radius(0); } + +// Reset fonts for other sizes +.btn-group > .btn-mini, +.btn-group > .btn-small { + font-size: @baseFontSize - 2px; +} +.btn-group > .btn-large { + font-size: @baseFontSize + 2px; +} + // 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 > .btn:first-child { margin-left: 0; diff --git a/less/tests/css-tests.html b/less/tests/css-tests.html index a61f6923a7..2396e348cf 100644 --- a/less/tests/css-tests.html +++ b/less/tests/css-tests.html @@ -953,6 +953,34 @@ +<!-- Button groups +================================================== --> + +<div class="page-header"> + <h1>Button groups</h1> +</div> + +<table class="table table-bordered"> + <tbody> + <tr> + <td> + Maecenas faucibus mollis interdum. Nulla vitae elit libero, a pharetra augue. Donec ullamcorper nulla non metus auctor fringilla. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. + </td> + <td> + <div class="btn-group"> + <button class="btn">1</button> + <button class="btn">2</button> + <button class="btn">3</button> + <button class="btn">4</button> + </div> + </td> + </tr> + </tbody> +</table> + + + + |