标签的Bootstrap对齐

时间:2016-08-12 04:26:24

标签: twitter-bootstrap twitter-bootstrap-3

我正在尝试创建一个表单,其中包含1个控件,2个控件和3个控件以及顶部的标签组。以下是我的HTML。有人可以帮我调整以下表格吗?

<div class=" col-xs-6 col-xs-offset-3">
                            <div class="row">
                               <label>Label1</label><span class="mandatory">*</span>
                               <div>
                                    <div class="col-sm-2 col-xs-12 form-group">                                        
                                        <select class="form-control input-sm"></select>
                                    </div>
                                    <div class="col-sm-5 col-xs-12 form-group">                                        
                                        <input type="text" class="form-control input-sm"
                                            required />
                                    </div>
                                    <div class="col-sm-5 col-xs-12 form-group">                                            
                                        <input type="text" class="form-control input-sm" required />
                                    </div>
                              </div>
                            </div>
                            <div class="row">
                                <label>Label2</label><span class="mandatory">*</span>
                                <div>
                                <div class="col-xs-12 form-group">
                                    <input type="text" class="form-control input-sm" required />
                                </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6 col-xs-12 form-group">
                                    <label>Label3</label><span class="mandatory">*</span>
                                <div class="input-group date">
                                    <label class="input-group-addon">##</label>
                                    <input type="text" class="form-control" />
                                </div>
                                </div>

                                <div class="col-sm-6 col-xs-12 form-group">
                                    <label>Label4</label><span class="mandatory">*</span>
                                    <input type="text" class="form-control" />
                                </div>

                            </div>
                            <div class="row">
                                <label>Label5</label><span class="mandatory">*</span>
                                <div>
                                    <div class="col-sm-2 col-xs-12 form-group">
                                        <input type="text" class="form-control input-sm" required />
                                    </div>
                                    <div class="col-sm-5 col-xs-12 form-group">
                                        <input type="text" class="form-control input-sm" required />
                                    </div>
                                    <div class="col-sm-5 col-xs-12 form-group">
                                        <input type="text" class="form-control input-sm" required />
                                    </div>
                                    <div class="col-sm-6 col-xs-12 form-group">
                                        <input type="text" class="form-control input-sm" required />
                                    </div>
                                    <div class="col-sm-6 col-xs-12 form-group">
                                        <select class="form-control input-sm"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <label>Label6</label><span class="mandatory">*</span>
                                <div>
                                <div class="col-xs-12 form-group">
                                    <input type="email" class="form-control input-sm" required />
                                </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm-6 col-xs-12 form-group">
                                    <label>Label7</label><span class="mandatory">*</span>
                                    <input type="text" class="form-control" required />
                                </div>

                                <div class="col-sm-6 col-xs-12 form-group">
                                    <label>Label8</label>
                                    <input type="text"  class="form-control" required />
                                </div>

                            </div>     </div>

小提琴链接https://jsfiddle.net/nxLz2up3/

1 个答案:

答案 0 :(得分:0)

试试这个

<div class=" col-xs-6 col-xs-offset-3">
      <div class="row">
        <div class="col-md-12">
          <label>Label1</label>
          <span class="mandatory">*</span>
        </div>
        <div>
          <div class="col-sm-2 col-xs-12 form-group">
            <select class="form-control input-sm"></select>
          </div>
          <div class="col-sm-5 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
          <div class="col-sm-5 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <label>Label2</label>
          <span class="mandatory">*</span>
        </div>
        <div>
          <div class="col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-6 col-xs-12 form-group">
          <label>Label3</label>
          <span class="mandatory">*</span>
          <div class="input-group date">
            <label class="input-group-addon">##</label>
            <input type="text" class="form-control">
          </div>
        </div>
        <div class="col-sm-6 col-xs-12 form-group">
          <label>Label4</label>
          <span class="mandatory">*</span>
          <input type="text" class="form-control">
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <label>Label5</label>
          <span class="mandatory">*</span>
        </div>
        <div>
          <div class="col-sm-2 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
          <div class="col-sm-5 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
          <div class="col-sm-5 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
          <div class="col-sm-6 col-xs-12 form-group">
            <input type="text" class="form-control input-sm" required="">
          </div>
          <div class="col-sm-6 col-xs-12 form-group">
            <select class="form-control input-sm"></select>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-md-12">
          <label>Label6</label>
          <span class="mandatory">*</span>
        </div>
        <div>
          <div class="col-xs-12 form-group">
            <input type="email" class="form-control input-sm" required="">
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col-sm-6 col-xs-12 form-group">
          <label>Label7</label>
          <span class="mandatory">*</span>
          <input type="text" class="form-control" required="">
        </div>
        <div class="col-sm-6 col-xs-12 form-group">
          <label>Label8</label>
          <input type="text" class="form-control" required="">
        </div>
      </div>
    </div>