Bootstrap:如何在中心对齐按钮组(垂直)

时间:2016-05-06 12:56:30

标签: css twitter-bootstrap button center

在以下代码中:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<div class="container">
    <div class="row">
	<div class="col-lg-12">
		<div class="panel panel-primary">
			<div class="panel-heading"><h2>Element Selection</h2></div>
			<div class="panel-body">
				<div class="row">
					<div class="col-lg-5">
						<div class="form-group">
							<h3><span class="label label-info">Element Segment</span></h3>
							<textarea class="form-control" rows="8"></textarea>
						</div>
					</div>
					<div class="col-lg-2 text-center" >
						
						<div class="btn-group-vertical">
							<button type="button" class="btn btn-primary">>></button>
							<button type="button" class="btn btn-primary"><<</button>
							<button type="button" class="btn btn-primary">ALL>></button>
							<button type="button" class="btn btn-primary"><< ALL</button>
						</div>
						
					</div>
					<div class="col-lg-5">
						<div class="form-group">
							<h3><span class="label label-success">Element Segment</span></h3>
							<textarea class="form-control" rows="8"></textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

</div>
</div>
&#13;
&#13;
&#13;

现在结果如下: enter image description here

所以我可以将按钮组垂直放在中心位置。我搜索并尝试vertical-align: middle,但它对我没用。

2 个答案:

答案 0 :(得分:0)

您可以Flexbox使用媒体查询DEMO1200px用于.col-lg-

@media(min-width: 1200px) {
  .flex-row {
    display: flex;
    align-items: center;
  }
}

答案 1 :(得分:0)

@Nenad Vracar已发布的答案,但你也可以试试这个

 .flex-row {
    display: flex;
    align-items: center;
  }

DEMO HERE