屏幕上的分割按钮下拉线换行调整大小和选项选项

时间:2016-02-25 16:58:01

标签: html css twitter-bootstrap dropdown

我正在使用分割按钮下拉菜单,我想知道是否有办法停止下拉按钮的包装?

以前,我有

<div class="btn-group btn-block"> // btn-block

即使屏幕调整大小,分割按钮也会换行:

enter image description here

但我能够找到解决方法(GitHub Issue Link

<div class="btn-group" style="width:100px;"> // Removed btn-block class, added style

enter image description here

但是现在如果我从Dropdown中选择一个选项,无论屏幕大小/列宽如何,它都会再次被包裹(只要有足够的btn-block类,这个问题就不存在了专栏中的房间):

enter image description here

无论屏幕大小或选择的选项如何,我都希望下拉菜单不会换行。另外,我确实使用col-md - *

设置了列的宽度

此外,当选择长选项时,它会开始重叠到下一列: enter image description here

我希望我提供了足够的信息来启动有意义的回应。

JSFiddle Demo

<div class="col-lg-10" id="mapColumn">
<div>
<table class="table table-condensed tablesaw tablesaw-stack table-striped-column" data-tablesaw-mode="stack" id="table2">
<thead>
<tr>
  <th class="col-md-2">Map Actions</th>
  <th class="col-md-2">DB Actions</th>
  <th class="col-md-1">ID</th>
  <th class="col-md-3">Name</th>
  <th class="col-md-3">Features</th>
  <th class="col-md-1">Rating</th>
</tr>
</thead>
<tbody>

<tr>
  <td>
    <!-- <div class="btn-group btn-block"> -->
    <div class="btn-group" style="width:100px;">
      <button type="button" class="btn btn-sm btn-success">Actions</button>
      <button type="button" class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" id="mapActions">
        <li><a>TOGGLE Map</a></li>
        <li><a>ROTATE View</a></li>
        <li><a>SAVE Pic to PC</a></li>
      </ul>
    </div>
  </td>

  <td>
    <!-- <div class="btn-group btn-block"> -->
    <div class="btn-group" style="width:100px;">
      <button type="button" class="btn btn-sm btn-success">Actions</button>
      <button type="button" class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" id="dbActions">
        <li><a>UPDATE Features</a></li>
        <li><a>SAVE POV to DB</a></li>
      </ul>
    </div>
  </td>

  <td>123456</td>
  <td>Street A & Street B and a very very very long name</td>
  <td>
    <span class="label label-success">Label One</span>
    <span class="label label-success">Label Two</span>
    <span class="label label-success">Label Three</span>
    <span class="label label-success">Label Four</span>
  </td>
  <td>★★★★★</td>
</tr>
</tbody>
</table>
</div>

1 个答案:

答案 0 :(得分:1)

您可以添加以下样式:

.btn-group {
  white-space: nowrap;
  font-size: 0;
}
.btn-group-vertical>.btn, .btn-group>.btn {
  display:inline-block;
  float:none;
}

基本上,这会使.btn元素内联,这反过来又允许它利用nowrap白色间距。我还必须将按钮组设置为font-size:none以删除按钮之间的间距,但Twitter Bootstrap为按钮字体大小设置非相对像素值,因此在{{1}上设置font-size:0应该不是问题。我从.btn-group中移除了浮动,最后删除了标记中固定宽度.btn

https://jsfiddle.net/jmarikle/b4qtrfmb/

编辑:

或者,您也应该能够使用100px

display:flex

https://jsfiddle.net/jmarikle/b4qtrfmb/1/