如果您查看以下示例,您可以看到输入组位于按钮组下方:
我已经尝试将这两个组放入浮动 div 中,但浏览器仍然打破了行。我注意到“.btn-group, .btn-group-vertical”包含一个“display: inline-block”。注释掉这一行后,行没有中断,但我在两个 div 之间没有空格(虽然我想通过“padding-right: 16px”得到一个)
如果您查看以下示例,您可以看到输入组位于按钮组下方:
我已经尝试将这两个组放入浮动 div 中,但浏览器仍然打破了行。我注意到“.btn-group, .btn-group-vertical”包含一个“display: inline-block”。注释掉这一行后,行没有中断,但我在两个 div 之间没有空格(虽然我想通过“padding-right: 16px”得到一个)
找到了一个使用 table-display 容器的工作解决方案:
<div class="Toolbar">
<div>
<div class="btn-group">
<button id="ButtonCreate" class="btn btn-default btn-sm" onclick="CreateItem()" title="Erstellen"><span class="glyphicon glyphicon-file"></span></button>
<button id="ButtonUpdate" class="btn btn-default btn-sm" onclick="UpdateItem()" title="Bearbeiten"><span class="glyphicon glyphicon-pencil"></span></button>
<button id="ButtonDelete" class="btn btn-default btn-sm" onclick="DeleteItems()" title="Löschen"><span class="glyphicon glyphicon-trash"></span></button>
<button id="ButtonExport" class="btn btn-default btn-sm" onclick="ExportItems()" title="Exportieren"><span class="glyphicon glyphicon-export"></span></button>
</div>
</div>
<div>
<div class="input-group input-group-sm">
<span class="input-group-btn"><button id="ButtonSearch" class="btn btn-default btn-sm" onclick="SearchItem()" title="Suchen"><span class="glyphicon glyphicon-search"></span></button></span>
<input type="text" class="form-control" style="width: 300px;" placeholder="Suchen">
</div>
</div>
</div>
CSS(少):
.Toolbar
{
position: relative;
display: table;
}
.Toolbar > div
{
display: table-cell;
padding-right: 8px;
vertical-align: top;
}
.Toolbar
{
.btn-group, .btn-group-vertical
{
vertical-align: inherit;
}
}
怎么样
<div class="input-group input-group-sm">
<span class="input-group-btn btn-group-custom">
<button id="ButtonCreate" class="btn btn-default btn-sm" onclick="CreateItem()" title="Erstellen"><span class="glyphicon glyphicon-file"></span></button>
<button id="ButtonUpdate" class="btn btn-default btn-sm" onclick="UpdateItem()" title="Bearbeiten"><span class="glyphicon glyphicon-pencil"></span></button>
<button id="ButtonDelete" class="btn btn-default btn-sm" onclick="DeleteItems()" title="Löschen"><span class="glyphicon glyphicon-trash"></span></button>
<button id="ButtonExport" class="btn btn-default btn-sm" onclick="ExportItems()" title="Exportieren"><span class="glyphicon glyphicon-export"></span></button>
<button id="ButtonSearch" class="btn btn-default btn-sm" onclick="SearchItem()" title="Suchen"><span class="glyphicon glyphicon-search"></span></button>
</span>
<input class="form-control" style="width: 300px;" placeholder="Suchen" type="text">
</div>
您需要手动折叠边框并在悬停时调整它们并用于签证空间:
.btn-group-custom .btn {
border-right-width: 0;
}
.btn-group-custom .btn:hover {
border-right-width: 1px;
}
.btn-group-custom .btn:hover + .btn {
border-left-width: 0;
}
#ButtonSearch {
border-left-width: 1px;
border-right-width: 0;
margin-left: 16px;
}
#ButtonExport {
border-right-width: 1px;
}