将Bootstrap开关与另一个元素对齐
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将Bootstrap开关与另一个元素对齐相关的知识,希望对你有一定的参考价值。
所以我有这些元素,如图所示...
<style>
.btnautodesigner
margin-left: 5px;
.form-group-centered
width: 400px;
margin: 0 auto;
</style>
<div class="form-group row">
<div class="col-xs-12">
<div class="form-group-centered">
<div class="input-group pull-left" style="width: 220px;">
<span class="input-group-addon"> <input type="checkbox" id="allowbreak"> Break After </span>
<input type="text" class="form-control" id="c_count" value="20" onblur="c_count_onblur()" style="text-align: center;">
</div>
<button id="btnautodesigner" type="button" class="btn btn-default btn-md btnautodesigner pull-left" style="">Autodesigner</button>
</div>
<input type="checkbox" data-toggle="switch" id="split_state" data-handle-width="75" data-on-text="Split" data-off-text="Do Not Split">
</div>
</div>
我目前有以上代码。我该如何编码使其具有以下输出?
抱歉,我似乎无法弄清楚。我尝试将开关移到不同的部分,但是会产生奇怪的元素排列。谢谢。
答案
如果全屏运行code snippet
,您将看到它们以horizontally
为中心
实时演示:https://jsfiddle.net/czaL5wyf/
.center-me
position: absolute;
left: 50%;
transform: translate(-50%, 0);
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!--html -->
<div class="form-group center-me">
<div class="form-group-centered">
<div class="input-group pull-left" style="width: 220px; margin-right: 4px;">
<span class="input-group-addon"> <input type="checkbox" id="allowbreak"> Break After </span>
<input type="text" class="form-control" id="c_count" value="20" onblur="c_count_onblur()" style="text-align: center;">
</div>
<div class="input-group pull-left" style="width: 240px; margin-right: 4px;">
<input type="text" class="form-control" id="c_count" value="" onblur="c_count_onblur()" style="text-align: center;">
<span class="input-group-addon">Do not Split</span>
</div>
<button id="btnautodesigner" type="button" class="btn btn-default btn-md btnautodesigner pull-left">Autodesigner</button>
</div>
</div>
以上是关于将Bootstrap开关与另一个元素对齐的主要内容,如果未能解决你的问题,请参考以下文章