我试图将两个引导按钮并排(水平)对齐,现在它们一个在另一个上方(垂直)对齐。我在这里找到了一些问题,但似乎仍然无法做到......
我将在下面发布我的代码:
<div class="row">
<div class="col-sm-12">
<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btn btn-primary btn-md center-block" Style="width: 100px; margin-bottom: 10px;" OnClick="btnSearch_Click" />
<asp:Button ID="btnClear" runat="server" Text="Clear" CssClass="btn btn-danger btn-md center-block" Style="width: 100px;" OnClick="btnClear_Click" />
</div>
</div>
答案 0 :(得分:18)
1)使用display: inline-block
#btnSearch,
#btnClear{
display: inline-block;
vertical-align: top;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-sm-12 text-center">
<button id="btnSearch" class="btn btn-primary btn-md center-block" Style="width: 100px;" OnClick="btnSearch_Click" >button</button>
<button id="btnClear" class="btn btn-danger btn-md center-block" Style="width: 100px;" OnClick="btnClear_Click" >button</button>
</div>
</div>
或
2)删除课程.center-block
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-sm-12 text-center">
<button class="btn btn-primary btn-md">button</button>
<button class="btn btn-danger btn-md">button</button>
</div>
</div>
答案 1 :(得分:10)
<div class="container">
<div class="row">
<div class="col-xs-6">
<button class="btn btn-warning btn-block">Talent-signup to find jobs</button>
</div>
<div class="col-xs-6">
<button class="btn btn-success btn-block">Employers- signup to hire talent</button>
</div>
</div>
答案 2 :(得分:4)
您可以将out div与类btn-group
一起使用。这有助于水平对齐按钮。对每个按钮div使用col-md-6
可能会使按钮错位,中间有不需要的空间。
<div class="btn-group">
<a href="#" class="btn btn-warning">Talent-signup to find jobs</a>
<a href="#" class="btn btn-success">Talent-signup to find jobs</a>
</div>
答案 3 :(得分:1)
尝试使用Bootstrap4。为我服务
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
</div>
答案 4 :(得分:0)
这对我有用
<div class="container">
<div class="row">
<div class="col">
<button class="btn btn-danger form-control btn-block" routerLink='/login'>Cancel</button></div>
<div class="col">
<button id="btnSubmit" class="btn btn-primary form-control btn-block" type="submit" (click)="onSubmit()">Submit</button></div>
</div>
</div>