我使用Bootstrap并尝试使用按钮在同一行放置一些文本。我需要在按钮之前显示一些单词,之后再显示其他一些单词。 这就是我所拥有的:
<div class="input-group">
Match
<div class="input-group-btn" id="drop_operator_list">
<div class="btn-group btn-group-xs">
<div class="dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" id="modal-button-and-or" type="button" data-toggle="dropdown" data-target="#">
<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-and-or" id="and-or" style="height: auto; max-height: 200px; overflow-x: hidden;">
<li><a href="#" id="AND">AND</a></li>
<li><a href="#" id="OR">OR</a></li>
</ul>
</div>
</div>
</div>
Everything
</div>
答案 0 :(得分:2)
这是一种实现它的方法,只需添加一组div
标记并将字词移到输入组之外。还有Bootply。
<div class="form-inline">
Match
<div class="input-group">
<div class="input-group-btn" id="drop_operator_list">
<div class="btn-group btn-group-xs">
<div class="dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" id="modal-button-and-or" type="button" data-toggle="dropdown" data-target="#">
<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-and-or" id="and-or" style="height: auto; max-height: 200px; overflow-x: hidden;">
<li><a href="#" id="AND">AND</a></li>
<li><a href="#" id="OR">OR</a></li>
</ul>
</div>
</div>
</div>
</div>
Everything
</div>
正如所建议的,添加此CSS将抵消.form-inline
的768px的突破。
.form-inline .input-group {
display: inline-table; vertical-align: middle;
}
.form-inline .input-group .input-group-btn {
width: auto;
}
答案 1 :(得分:2)
您需要为.input-group
和.input-group-btn
设置一些属性:
@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.input-group {
display: inline-table;
vertical-align: middle;
}
.input-group .input-group-btn {
width: auto;
}
<div class="input-group">
Match
<div class="input-group-btn" id="drop_operator_list">
<div class="btn-group btn-group-xs">
<div class="dropdown">
<button class="btn btn-primary btn-xs dropdown-toggle" id="modal-button-and-or" type="button" data-toggle="dropdown" data-target="#">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-and-or" id="and-or" style="height: auto; max-height: 200px; overflow-x: hidden;">
<li><a href="#" id="AND">AND</a>
</li>
<li><a href="#" id="OR">OR</a>
</li>
</ul>
</div>
</div>
</div>
Everything
</div>