html - 将 Bootstrap btn-group 添加到面板标题会在面板标题下方添加空间

标签 html css twitter-bootstrap

我试图将一个按钮放入面板标题部分,但我无法让它显示在同一行上。在 StackOverflow 上的一些问题的帮助下,我设法让它居中,其他人询问标题右侧的按钮,但添加按钮似乎会使标题更高。

我有一个显示差异的示例 Bootply

代码

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default" ng-init="getApplications()">
    <div class="panel-heading clearfix">
       <b>Title has space below</b>
         <div class="btn-group pull-right">
          <a href="#" class="btn btn-default btn-sm">new</a>
        </div>
     </div>
    <div class="panel-body">
        <!-- table -->
        <table class="table table-striped table-condensed table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Last Release Date</th>
                    <th>Orders</th>
                    <th>Downloads</th>
                    <th>Activations</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="app in apps">
                    <td>{{app.columns.name}}</td>
                    <td>{{app.lastReleaseDt}} </td>
                    <td>{{app.totalOrders}}</td>
                    <td>TODO </td>
                    <td>{{app.totalActivations}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<div class="panel panel-default" ng-init="getApplications()">
    <div class="panel-heading clearfix">
       <b>Title has no space</b>
     </div>
    <div class="panel-body">
        <!-- table -->
        <table class="table table-striped table-condensed table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Last Release Date</th>
                    <th>Orders</th>
                    <th>Downloads</th>
                    <th>Activations</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="app in apps">
                    <td>{{app.columns.name}}</td>
                    <td>{{app.lastReleaseDt}} </td>
                    <td>{{app.totalOrders}}</td>
                    <td>TODO </td>
                    <td>{{app.totalActivations}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

有人知道为什么向面板标题添加按钮或按钮组会增加高度吗?关于将高度设置为按钮之前的高度的任何提示?

最佳答案

因为您使用的是 btn-sm(适用于小型设备),如果您使用 btn-xs(适用于超小型设备),空间将会消失,因为拥有更小的 padding

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="panel panel-default" ng-init="getApplications()">
    <div class="panel-heading clearfix">
       <b>Title has space below</b>
         <div class="btn-group pull-right">
          <a href="#" class="btn btn-default btn-xs">new</a>
        </div>
     </div>
    <div class="panel-body">
        <!-- table -->
        <table class="table table-striped table-condensed table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Last Release Date</th>
                    <th>Orders</th>
                    <th>Downloads</th>
                    <th>Activations</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="app in apps">
                    <td>{{app.columns.name}}</td>
                    <td>{{app.lastReleaseDt}} </td>
                    <td>{{app.totalOrders}}</td>
                    <td>TODO </td>
                    <td>{{app.totalActivations}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<div class="panel panel-default" ng-init="getApplications()">
    <div class="panel-heading clearfix">
       <b>Title has no space</b>
     </div>
    <div class="panel-body">
        <!-- table -->
        <table class="table table-striped table-condensed table-hover">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Last Release Date</th>
                    <th>Orders</th>
                    <th>Downloads</th>
                    <th>Activations</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="app in apps">
                    <td>{{app.columns.name}}</td>
                    <td>{{app.lastReleaseDt}} </td>
                    <td>{{app.totalOrders}}</td>
                    <td>TODO </td>
                    <td>{{app.totalActivations}}</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

关于html - 将 Bootstrap btn-group 添加到面板标题会在面板标题下方添加空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35959515/

相关文章:

twitter-bootstrap - 当在移动设备上显示行时, Bootstrap 响应网格更改列的顺序?

javascript - 单选按钮的值

javascript - 如何返回 HTML 中的 json 对象值列表的总和

html - border-radius 在表单元素文本中只显示两条边

html - 谷歌网络字体在火狐浏览器中模糊

html - 为什么是:hover not working for tr element?

javascript - 使用折叠的 Bootstrap 导航栏上的按钮切换隐藏类 ="hidden-xs"的特定 div 的显示

html - 如何在 Firefox 中使 <div> 填充 <td> 高度

css - Ionic 中的错误框

css - 使用 Bootstrap table-condensed 类使表格宽度固定