twitter-bootstrap Bootstrap 3 右拉不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21305209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:49:06  来源:igfitidea点击:

Bootstrap 3 pull-right not working

csstwitter-bootstraptwitter-bootstrap-3

提问by Polyethylene

I am creating a multi column form using Bootstrap 3.

我正在使用 Bootstrap 3 创建一个多列表单。

Here is the first column.

这是第一列。

<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <form class="form-inline" role="form">
                <div class="row">
                    <div class="col-md-3">
                        <div class="form-group">
                             <label for="RecordID" class="col-md-4 nopadding">Record ID</label><div class="col-md-8 nopadding pull-right"><input class="form-control" id="RecordID" type="text"></div>
                        </div>
                        <div class="form-group">
                             <label for="ID" class="col-md-5 nopadding">ID</label><div class="col-md-7 nopadding pull-right"><input class="form-control" id="ID" type="text"></div>
                        </div>
                        <div class="form-group nopadding">
                             <label for="FamilyName" class="col-md-5 nopadding">Family Name</label><div class="col-md-7 nopadding"><input class="form-control" id="FamilyName" type="text" maxlength="30"></div>
                        </div>
                        <div class="form-group">
                             <label for="GivenName" class="col-md-5 nopadding">Given Name</label><div class="col-md-7 nopadding"><input class="form-control" id="GivenName" type="text" maxlength="30"></div>
                        </div>
                        <div class="form-group">
                             <label for="MiddleName" class="col-md-5 nopadding">Middle Name</label><div class="col-md-7 nopadding"><input class="form-control" id="MiddleName" type="text" maxlength="30"></div>
                        </div>
                    </div>
                    //other column
                </div>
            </form>
        </div>
    </div>
</div>

However, I got the first column looks like this.

但是,我得到的第一列看起来像这样。

I want the text fields align to the right

我希望文本字段向右对齐

I wanted to align the text fields to the right so I added the "pull-right" class to the div that encapsulated the text field of ID. However, it doesn't work.

我想将文本字段向右对齐,因此我将“pull-right”类添加到封装了 ID 文本字段的 div。但是,它不起作用。

Here is the JSFiddle link, you will find the nopadding class in the link, it just remove the padding. The result box of JSFiddle is not large enough by default, you will need to pull the result box to get the result I got.: JSFiddle link

这是 JSFiddle 链接,您会在链接中找到 nopadding 类,它只是删除了填充。JSFiddle的结果框默认不够大,需要拉结果框才能得到我得到的结果:JSFiddle链接

采纳答案by Sobin Augustine

add class="form-group col-md-12 nopadding" to div which was currently <div class="form-group">

将 class="form-group col-md-12 nopadding" 添加到当前的 div <div class="form-group">

回答by schauboga

I would suggest something like that:

我会建议这样的:

<div class="container nopadding">
<form class="form-horizontal" role="form">
    <div class="form-group">
        <label for="recordId" class="col-sm-2 control-label">Record Id</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="recordId" placeholder="Record Id">
        </div>
    </div>
    <div class="form-group">
        <label for="id" class="col-sm-2 control-label">Id</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="id" placeholder="Password">
        </div>
    </div>
    <div class="form-group">
        <label for="familyName" class="col-sm-2 control-label">Family Name</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="familyName" placeholder="Family Name" maxlength="30">
        </div>
    </div>
    <div class="form-group">
        <label for="givenName" class="col-sm-2 control-label">Given Name</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="givenName" placeholder="Given Name" maxlength="30">
        </div>
    </div>
    <div class="form-group">
        <label for="middleName" class="col-sm-2 control-label">Middle Name</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" id="middleName" placeholder="Middle Name" maxlength="30">
        </div>
    </div>
</form>

http://jsfiddle.net/y838v/3/

http://jsfiddle.net/y838v/3/

Based on http://getbootstrap.com/css/#forms-horizontal

基于http://getbootstrap.com/css/#forms-horizo​​ntal