2016-06-21 41 views
0

我正在使用引導程序的網格來模仿像結構的表。跨度佔用兩行空間,看起來和預期的一樣,但如果我嘗試向包含的div添加頁邊空白,它似乎將其添加到頂部。divs與跨度內不正確的距離

我希望在每次潛水後留出空間,讓他們看起來更加分組。遵循這種結構有沒有辦法做到這一點?

https://jsfiddle.net/daltonj1130/7Ltstbhp/

var h = $('#x').height(); 
 
console.log(h); 
 
$('.dclass').css('padding-bottom', 2 * h + 1).css('border', '1px solid grey')
.dclass { 
 
    margin-bottom: 10px; 
 
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
 
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> 
 

 
<div class="dclass"> 
 
    <span id="x" class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;"> 
 
    Action 
 
    <select class="form-control" name="act1"> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;"> 
 
    Pay Type 
 
    <select class="form-control" name="act2"> 
 
     <option value=""></option> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Date 
 
    <input type="text" name="act3" class="form-control" value="date"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Start Time 
 
    <input type="time" name="act4" class="form-control" value="act4"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">End Time 
 
    <input type="time" name="act5" class="form-control" value="act5"></span> 
 
</div> 
 

 
<div class="dclass"> 
 
    <span class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;">Action 
 
    <input type="hidden" name="act" value="act"/> 
 
    <select class="form-control" name="act1"> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;">Pay Type 
 
    <select class="form-control" name="act2"> 
 
     <option value=""></option> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Date 
 
    <input type="text" name="act3" class="form-control" value="date"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Start Time 
 
    <input type="time" name="act4" class="form-control" value="act4"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">End Time 
 
    <input type="time" name="act5" class="form-control" value="act5"></span> 
 
</div> 
 

 
<div class="dclass"> 
 
    <span class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;"> 
 
    Action 
 
    <select class="form-control" name="act1"> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-6 col-sm-6 col-md-3 col-lg-6" style="padding:0;">Pay Type 
 
    <select class="form-control" name="act2"> 
 
     <option value=""></option> 
 
    </select> 
 
    </span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Date 
 
    <input type="text" name="act3" class="form-control" value="date"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">Start Time 
 
    <input type="time" name="act4" class="form-control" value="act4"></span> 
 
    <span class="col-xs-4 col-sm-4 col-md-2 col-lg-4" style="padding:0;">End Time 
 
    <input type="time" name="act5" class="form-control" value="act5"></span> 
 
</div>

+0

附加到問題的jsfiddle現在是工作版本。 (最初是需要修復的) – Daffy13

回答

0

我最終找到了一個修復程序,將div的填充底部設置爲其中跨度的高度。然後我添加了一個空白底部以在每個div之間添加空間

0

你的div沒有高度。如果您不知道原因,只需將height:auto !important插入他們的風格或課程或其他內容。

+0

這似乎沒有任何影響 – Daffy13