我有这个HTML:
<h4><span class="label label-default">1546 - some text</span></h4>
<div class="pull-left">
<button type="button" class="btn btn-primary" ng-click="list.saveItems();" ng-disabled="!list.currentItems.length || list.currentItemsStatus.id == 1">Submit</button>
<button type="button" class="btn btn-default" ng-click="list.getItems()">Reload</button>
<button type="button" class="btn btn-default" ng-disabled="true">Cancel</button>
</div>
如何使用右侧的按钮在同一行上创建元素?
答案 0 :(得分:6)
您必须添加以下CSS:
h4 {
display:inline-block;
float:left;
}
display
属性的默认值为block
,因此标题采用父容器的整个宽度。使用display:inline-block
只需要所需的空间。
仅使用Bootstrap的另一种解决方案
您可以将班级pull-left
设置为<h4>
。所以你不需要额外的CSS规则:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<h4 class="pull-left"><span class="label label-default">1546 - some text</span></h4>
<div class="pull-left">
<button type="button" class="btn btn-primary" ng-click="list.saveItems();" ng-disabled="!list.currentItems.length || list.currentItemsStatus.id == 1">Submit</button>
<button type="button" class="btn btn-default" ng-click="list.getItems()">Reload</button>
<button type="button" class="btn btn-default" ng-disabled="true">Cancel</button>
</div>
&#13;
答案 1 :(得分:1)
您必须为h4
和pull-left
添加一些CSS - class:
h4{
display: inline-block;
}
.pull-left{
display: inline-block;
}
示例: