2017-09-27 94 views
0

我有一個Bootstrap頁面,在一張表格上方的單個row中顯示帶有2個窗體的標題。帶有2個輸入的第二種形式出現在表格的左上角,佔據了父列的整個寬度(col-md-8) - 它只需佔據該列寬度的一半左右。Bootstrap列/網格大小問題

我無法弄清楚如何定位,所以它佔用較少的空間,但仍然與標題/表格的左側同時對齊。下面是它目前的樣子(請確保您使用完整的頁面選項,看看這個,因爲它會在桌面上才能使用):

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 

 
<div class="container"> 
 

 
<div class="row"> 
 
    <div class="col-md-8"> 
 
    <h1>Items List</h1> 
 

 
    <br> 
 
    <br> 
 
    <br> 
 
    <br> 
 
    <br> 
 
    <br> 
 
    <br> 
 

 
    <form class="form-horizontal" id="findItems" action="#" method="get" role="form"> 
 
     <input type="hidden" name="action" value="findItems"> 
 
     <table class="table table-bordered"> 
 
     <tr> 
 
      <td><input type="text" class="form-control" name="itemID" id="itemID" placeholder="Shipment ID"></td> 
 
      <td><input type="text" class="form-control datepicker" name="shippingDate" id="shippingDate" data-date-format="dd/mm/yyyy" placeholder="Date Shipped"></td> 
 
      <td class="text-center"> 
 
      <button type="submit" class="btn btn-success">Update All</button> 
 
      </td> 
 
     </tr> 
 
     </table> 
 

 
    </form> 
 

 

 

 
    </div> 
 
    <!-- /.col-md-8--> 
 

 

 
    <div class="col-md-4"> 
 

 
    <div> 
 
     <form class="form-horizontal" id="findMoreItems" action="#" method="get" role="form"> 
 
     <input type="hidden" name="action" value="findMoreItems"> 
 
     <table class="table table-bordered"> 
 
      <tr> 
 
      <td>Shipment ID:</td> 
 
      <td><input type="text" class="form-control" name="shipmentID" id="shipmentID" placeholder="Shipment ID"></td> 
 
      </tr> 
 
      <tr> 
 
      <td>Authority ID:</td> 
 
      <td><input type="text" class="form-control" name="authorityID" id="authorityID" placeholder="Authority ID"></td> 
 
      </tr> 
 
      <tr> 
 
      <td>Ref ID:</td> 
 
      <td><input type="text" class="form-control" name="refID" id="refID" placeholder="Ref ID"></td> 
 
      </tr> 
 
      <tr> 
 
      <td>Serial Number:</td> 
 
      <td><input type="text" class="form-control" name="serialNumber" id="serialNumber" placeholder="Serial #"></td> 
 
      </tr> 
 
      <tr> 
 
      <td colspan="2" class="text-center"> 
 
       <button type="reset" class="btn btn-default">Reset</button> 
 
       <button type="submit" class="btn btn-success">Search</button> 
 
      </td> 
 
      </tr> 
 
     </table> 
 

 
     </form> 
 
    </div> 
 

 
    </div> 
 
    <!-- /.col-md-4--> 
 

 
</div> 
 
<!-- /.row--> 
 

 

 

 

 
<br> 
 

 

 
<div> 
 

 
    <br /> 
 
    <table class="table table-condensed table-striped table-bordered"> 
 
    <thead> 
 
     <th class="text-center" scope="col">Shipment ID</th> 
 
     <th class="text-center" scope="col">Item ID</th> 
 
     <th class="text-center" scope="col">Serial Number</th> 
 
     <th class="text-center" scope="col">Shipped Date</th> 
 
    </thead> 
 
    <tbody> 
 
</tbody> 
 
\t \t \t \t </table> 
 
\t \t 
 
</div> 
 

 
</div><!-- /.container -->

+0

使用偏移Class =「col-md-4 col-md-offset-4」,所以你的列很大4並移位了4 –

回答

0

你總是可以只添加一個間隔器柱。所以...

<div class="col-md-6"> two table things </div> 
<div class="col-md-2"> empty column for spacing </div> 
<div class="col-md-4"> other table </div>