2016-11-22 65 views
-5

我需要使用條形表(boostrap),但需要滾動。在我的代碼中,我只是調用類表表格,並且表格看起來很好。現在我需要爲保持相同樣式的同一張表添加滾動條。這是可行的嗎?怎麼樣?我可以在html中添加滾動條紋表(boostrap)嗎?

下面是我的一些代碼

<div class="row col-sm-12"> 
<div class="col-sm-7"> 
    <div class="table-responsive"> 
    <table class="table table-hover table-striped"> 
    <thead> 
<tr> 
    <th>Make</th> 
    <th>Model</th> 
    <th>Color</th> 
    <th>Year</th> 
</tr> 
</thead> 
<tbody> 
<tr> 
    <td class="filterable-cell">Ford</td> 
    <td class="filterable-cell">Escort</td> 
    <td class="filterable-cell">Blue</td> 
    <td class="filterable-cell">2000</td> 
</tr> 
<tr> 
    <td class="filterable-cell">Ford</td> 
    <td class="filterable-cell">Escort</td> 
    <td class="filterable-cell">Blue</td> 
    <td class="filterable-cell">2000</td> 
</tr> 
     <tr> 
    <td class="filterable-cell">Ford</td> 
    <td class="filterable-cell">Escor</td> 
    <td class="filterable-cell">Blue</td> 
    <td class="filterable-cell">2001</td> 
</tr> 
</tbody> 
</table> 
    </div>   
    </div> 
    </div> 

我不知道在哪裏可以找到CSS代碼。我使用了一個boostrap模板。

+0

你能告訴我們一些代碼嗎? –

+0

我還添加了桌子和桌子胡佛班。所以我需要保留我提到的所有三種風格。 –

+0

請修改並添加你的代碼並添加註釋 –

回答

0

設置的高度和溢出-Y:滾動你的風格

table { 
    height: 30px; 
    overflow-y: scroll; 
} 

時的數據加載和空間是不夠的數據,表將顯示滾動。

<table style="border: 1px solid red"> 
    <thead> 
     <tr> 
      <td>Header stays put, no scrolling</td> 
     </tr> 
    </thead> 
    <tbody style="display: block; border: 1px solid green; height: 30px; overflow-y: scroll"> 
     <tr> 
      <td>cell 1/1</td> 
      <td>cell 1/2</td> 
     </tr> 
     <tr> 
      <td>cell 2/1</td> 
      <td>cell 2/2</td> 
     </tr> 
     <tr> 
      <td>cell 3/1</td> 
      <td>cell 3/2</td> 
     </tr> 
    </tbody> 
</table> 
+0

在標記中複製以下內容 – Dilshan

+0

style =「height:30px; overflow-y:scroll」 根據需要更改高度 – Dilshan

相關問題