为了在面板标题中包含3个元素,我尝试了这个:
<div class="panel panel-primary">
<!-- Default panel header contents -->
<div class="panel-heading">
<h4 class="panel-title">
<div class="pull-left">
<h4 class="panel-title"> <i class="glyphicon glyphicon-user"></i>
Users
</h4>
</div>
<div class="header-center">
<pagination class="panel-title" ng-show="totalItems > pageParameters.size" items-per-page="pageParameters.size" boundary-links="true" total-items="totalItems" ng-model="currentPage" ng-change="changePage()"
previous-text="‹" next-text="›" first-text="«" last-text="»"></pagination>
</div>
<div class="pull-right">
<span class="panel-title btn-group">
<button ng-disabled="underCreation" type="button" class="btn btn-default btn-sm" ng-click="addUser()">
<span class="glyphicon glyphicon-plus text-primary"></span>
<span class="text-primary"><strong>Add</strong></span>
</button>
</span>
</div>
</h4>
<div class="clearfix"></div>
</div>
</div>
和.less文件对应:
.header-center {
display: flex;
justify-content: center;
align-items: center;
}
但这会呈现:
我需要添加按钮与其他元素对齐..
答案 0 :(得分:7)
您可以使用bootstrap网格来解决此问题 您可以使用col-xs-3,col-xs-6,col-xs-3创建3个并行列 检查代码以获得更多说明http://jsfiddle.net/5doxw0ea/
HTML:
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="container-fluid panel-container">
<div class="col-xs-3 text-left">
<h4 class="panel-title abc">
<i class="glyphicon glyphicon-user"></i>
Users
</h4>
</div>
<div class="col-xs-6 text-center ">
<ul class="pagination panel-pagination">
<li>
<a href="#" aria-label="Previous">
<span aria-hidden="true">«</span>
</a>
</li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li>
<a href="#" aria-label="Next">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</div>
<div class="col-xs-3 text-right">
<span class="panel-title btn-group">
<button ng-disabled="underCreation" type="button" class="btn btn-default btn-sm abc" ng-click="addUser()">
<span class="glyphicon glyphicon-plus text-primary"></span>
<span class="text-primary"><strong>Add</strong></span>
</button>
</span>
</div>
</div>
</div>
</div>
</div>
CSS:
.panel-pagination {
margin: 0 0 !important;
}
.panel-container {
padding-right: 0 !important;
padding-left: 0 !important;
height:35px;
}
.abc{
height:35px;
display:table-cell !important;
vertical-align:middle;
}
答案 1 :(得分:0)
如果你不需要一个完整的网格,你也可以将第三个div pull-right
移到第二个div header-center
之上。