使用引导程序缩小列之间的间隙

Posted

技术标签:

【中文标题】使用引导程序缩小列之间的间隙【英文标题】:Closing the gap between columns with bootstrap 【发布时间】:2019-03-23 00:24:39 【问题描述】:

我无法缩小引导程序中表格元素之间的差距。它给了我一个奇怪的 60% 的差距,我似乎无法修复。我相信这与我正在尝试实施的网格系统有关。我尝试过内联样式,但似乎无法缩小差距。谁能建议一个快速修复?

干杯

<div class="container">
   <table class="table table-striped">
      <tbody>
         <tr>
            <td colspan="1" >
               <form class="well form-horizontal">
                  <fieldset>
                     <div class="form-group">
                        <label class="col-md-4 control-label" style="width: 100%;">Which ArtSound Partner are you?</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group">
                              <span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
                              <select class="selectpicker form-control">
                                 <option>ANU School of Music</option>
                                 <option>Arts Society of Canberra</option>
                                 <option>Australian Festival of Chamber Music</option>
                                 <option>ANU School of Music</option>
                                 <option>ANU School of Music</option>
                                 <option>ANU School of Music</option>
                                 <option>ANU School of Music</option>
                              </select>
                           </div>
                        </div>
                        </div>
                     </div>
                     <div class="form-group">
                        <label class="col-md-4 control-label">Not an ArtSound partner?</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span><input id="eventname" name="eventname" placeholder="Event name
                          " class="form-control" required="true" value="" type="text">

                        </div>

                        <input type="checkbox" name="check" checked> <span class="label-text">Optional: Please send me information about becoming an arts partner</span>
                        </div>
                     </div>
                     <div class="form-group">
                        <label class="col-md-4 control-label">Name of your event</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span><input id="eventname1" name="eventname1" placeholder="Address Line 2" class="form-control" required="true" value="" type="text"></div>
                        </div>
                     </div>




                     <div class="form-group">
                        <label class="col-md-4 control-label">Please describe your event</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span><textarea id="city" name="city" placeholder="Please describe your event" class="form-control" required="true" value="" type="text" rows="5" onkeyup="countChar(this)"></textarea></div>
                           <span style="font-size: 12px;">Characters left: <span id="charNum">250</span></span>
                        </div>
                     </div>




              <div class="form-group">
                        <label class="col-md-4 control-label">Pick a date or type one in</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>



                            <input id="postcode" name="daterange" placeholder="Pick a date" class="form-control" required="true" value="" type="text">

                            <script>
          $(function() 
            $('input[name="daterange"]').daterangepicker(
             opens: 'left'
           , function(start, end, label) 
            -console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
             );
                  );
            </script>



                           </div>
                        </div>
                     </div>






                     <div class="form-group">
                        <label class="col-md-4 control-label">Pick a time</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span><input id="postcode" name="postcode" placeholder="00:00" class="form-control" required="true" value="" type="text"></div>
                        </div>
                     </div>



                  </fieldset>
               </form>
            </td>
            <td colspan="1">
               <form class="well form-horizontal">
                  <fieldset>

                    <div class="form-group">
                        <label class="col-md-12 control-label">Please enter your event's address</label>
                        <div class="col-md-12 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span><textarea id="city" name="city" placeholder="Please describe your event" class="form-control" required="true" value="" type="text" rows="5" onkeyup="countChar(this)"></textarea></div>
                           <span style="font-size: 12px;">Characters left: <span id="charNum">250</span></span>
                        </div>
                     </div>






                     <div class="form-group">
                        <label class="col-md-4 control-label">Web address</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span><input id="fullName" name="fullName" placeholder="http://" class="form-control" required="true" value="" type="text"></div>
                        </div>
                     </div>
                     <div class="form-group">
                        <label class="col-md-4 control-label">Email</label>
                        <div class="col-md-6 inputGroupContainer">
                           <div class="input-group"><span class="input-group-addon" style="max-width: 100%;"><i class="glyphicon glyphicon-home"></i></span><input id="addressLine1" name="addressLine1" placeholder="johnsmith@gmail.com" class="form-control" required="true" value="" type="text"></div>
                        </div>
                     </div>




                     </div>

                  </fieldset>
               </form>
            </td>
         </tr>
      </tbody>
   </table>
</div>

【问题讨论】:

你为什么用桌子? 如果你把它放在modal 中,不建议使用container,因为它会使你的模态变得难以管理 那是因为你使用了col-md-6。你不遵循引导程序的网格系统。 【参考方案1】:

我不确定您的问题,但在您的代码中看到您可以尝试:

    使用 row 类作为每个 col-*-* 元素的父级,例如在您的情况下使用 form-group 类。 您还可以将no-gutters 添加到row 类中,以删除每个col-*-* 类的填充 添加table-sm 以尽量减少表中行的填充。

【讨论】:

以上是关于使用引导程序缩小列之间的间隙的主要内容,如果未能解决你的问题,请参考以下文章

引导程序中两列之间的垂直分隔线

是否可以使用引导程序将边框添加到单独行内的 col

3 列网格导航栏引导程序

带有 CSS 过渡的引导程序

引导程序和大屏幕

在 jsFiddle 中使用 twitter 的引导程序