2017-05-15 5 views
0

Ich möchte wissen, warum mein td nicht 100% in meiner Tabelle bekommt.Tabelle td ist nicht 100%

dieser Code existieren müssen:

.table-scroll tbody { 
    display: block; 
    overflow-y: scroll; 
    height: calc(100% - 130px); 
} 

dies passieren, wenn ich Anzeigeblock verwenden, trotzdem habe ich versucht, so viele Dinge und die td noch nicht zu 100% der Tabelle

jsfiddle bekommen: https://jsfiddle.net/zuxq2gr0/1/

css:

.panel-table { 
    height:auto; 
    width:300px; 
    border: 1px solid red; 
} 

.table-scroll tbody { 
    display:block; 
    overflow-y: scroll; 
    height: calc(100% - 130px); 
} 

html:

<!doctype html> 
    <html> 
     <head> 
     <title>Aurelia</title> 
     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     </head> 
     <body> 
     <div class="panel-table"> 
      <table class="table table-scroll"> 
      <thead> 
      </thead> 
      <tbody> 
       <tr> 
       <td>Joseph</td> 
       </tr> 
       <tr> 
       <td>Mary</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
       <tr> 
       <td>Judy</td> 
       </tr> 
      </tbody> 
      </table> 
     </div> 
     </body> 

    </html> 

Antwort

2

Sie diesen Stil hinzufügen:

.table-scroll tbody > tr { 
    display: table; 
    width: 100%; 
} 

Hier wird ein fiddle aktualisiert

Warum Ihr tbodydisplay: block sein müssen? Du durchbrichst das Tabellenlayout und du wirst ein komisches Verhalten wie dieses bekommen.

1

Stellen Sie einfach 'tr' als 'display: block' zu und es sollte funktioniert

tr, td { 
    display: block; 
} 
+0

dies funktionieren wird, bis mehr 'td' Zellen hinzugefügt werden. Und an diesem Punkt, warum benutzt man sogar einen 'Tisch'? Es ist nur extra Markup ohne Nutzen. – zgood

+0

stimme ich voll und ganz zu – Vashnak

Verwandte Themen