Bootstrap 3: How to get two form inputs on one line and other inputs on individual lines?

前端 未结 4 1205
感情败类
感情败类 2020-12-15 15:56

I trying to format my registration page with Bootstrap 3.1.1. I would like the first two inputs to be on the same line while the other inputs are one there own line. I hav

相关标签:
4条回答
  • 2020-12-15 16:15

    You can wrap the inputs in col-* classes

    <form name="registration_form" id="registration_form" class="form-horizontal">
         <div class="form-group">
               <div class="col-sm-6">
                 <label for="firstname" class="sr-only"></label>
                 <input id="firstname" class="form-control input-group-lg reg_name" type="text" name="firstname" title="Enter first name" placeholder="First name">
               </div>       
               <div class="col-sm-6">
                 <label for="lastname" class="sr-only"></label>
                 <input id="lastname" class="form-control input-group-lg reg_name" type="text" name="lastname" title="Enter last name" placeholder="Last name">
               </div>
        </div><!--/form-group-->
    
        <div class="form-group">
            <div class="col-sm-12">
              <label for="username" class="sr-only"></label>
              <input id="username" class="form-control input-group-lg" type="text" autocapitalize="off" name="username" title="Enter username" placeholder="Username">
            </div>
        </div><!--/form-group-->
    
        <div class="form-group">
            <div class="col-sm-12">
            <label for="password" class="sr-only"></label>
            <input id="password" class="form-control input-group-lg" type="password" name="password" title="Enter password" placeholder="Password">
            </div>
        </div><!--/form-group-->
     </form>
    

    http://bootply.com/127825

    0 讨论(0)
  • 2020-12-15 16:16

    Use <div class="row"> and <div class="form-group col-xs-6">

    Here a fiddle :https://jsfiddle.net/core972/SMkZV/2/

    0 讨论(0)
  • 2020-12-15 16:19

    I resorted to creating 2 style cascades using inline-block for input that pretty much override the field:

    .input-sm {
        height: 2.1em;
        display: inline-block;
    }
    

    and a series of fixed sizes as opposed to %

    .input-10 {
        width: 10em;
    }
    
    .input-32 {
        width: 32em;
    }
    
    0 讨论(0)
  • 2020-12-15 16:24

    You can code like two input box inside one div

    <div class="input-group">
                <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <input style="width:50% " class="form-control " placeholder="first name"  name="firstname" type="text" />
                <input style="width:50% " class="form-control " placeholder="lastname"  name="lastname" type="text" />
            </div>
    
    0 讨论(0)
提交回复
热议问题