2016-04-07 12 views
3

Ich habe dieses Beispiel:Wie kann ich dieses div scroll mit display: table?

link

HTML-Code:

<div id="wrap"> 
    <div id="scrollable"> 
    <table class="table"> 
    <thead> 
     <tr> 
     <th>Firstname</th> 
     <th>Lastname</th> 
     <th>Email</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
     <td>John</td> 
     <td>Doe</td> 
     <td>[email protected]</td> 
     </tr> 
     <tr> 
     <td>Mary</td> 
     <td>Moe</td> 
     <td>[email protected]</td> 
     </tr> 
     <tr> 
     <td>July</td> 
     <td>Dooley</td> 
     <td>[email protected]</td> 
     </tr> 
    </tbody> 
    </table> 
    </div> 
</div> 

CODE CSS:

#wrap{ 
    display:table; //Here is the problem 
    background: #F7F7F7; 
} 
#scrollable{ 
    overflow-y:auto; 
} 
table{ 
    min-width:1000px; 
} 

Wenn Sie erhalten "display: table", wenn alles funktioniert einwandfrei, aber ich nicht wa Ich will ihn nicht aufgeben.

Ich möchte Scroll-Tabelle machen.

Es kann dies tun? Practicaly möchte ich #scrollable div bewegen haben, aber ohne die "display: table"

Cancelling Können Sie mir eine Lösung für dieses Problem zu finden bitte helfen?

Vielen Dank!

+0

wollen Sie für die Tabelle scrollen oder #scrollable? – Dimple

+0

können Sie mehr über Ihre Frage erklären? – Bhimbim

Antwort

1

Bitte versuchen Sie dies:

etwas Höhe Erwähnung für #scrollable

wie

#scrollable{ 
    overflow-y:auto; 
height:100px 
} 
+0

Sorry, ich wünschte horizontales Scrollen, ich habe mich geirrt –

0

dieses CSS hinzufügen:

table{ 
    min-width:1000px; 
    overflow-y:scroll; 
    height:50px; 
    display:block; 
} 

Für Horizontal:

table{ 
    width:100px; 
    overflow-y:scroll; 
    display:block; 
} 

Demo

+0

Entschuldigung, ich wünschte horizontales Scrollen, ich lag falsch –

+0

check Ich bearbeite meine Antwort –

+0

https://jsfiddle.net/L256Lm70/ Sind Sie sicher, dass es horizontal ist? –

0

Sie können zur Steuerung des Überlaufes mit dem Wrapper betrachten und Anzeige gelten: Tabelle nur auf den Tisch Element.

Beispiel unten.

#wrap { 
 
    height: 100px; 
 
    width: 450px; 
 
    background: #F7F7F7; 
 
    overflow-y: scroll; // make the wrapper scrollable 
 
    overflow-x: none; 
 
} 
 

 
#table { 
 
    display: table; // apply table layout 
 
}
<div id="wrap"> 
 
    <div id="scrollable"> 
 
    <table class="table"> 
 
     <thead> 
 
     <tr> 
 
      <th>Firstname</th> 
 
      <th>Lastname</th> 
 
      <th>Email</th> 
 
     </tr> 
 
     </thead> 
 
     <tbody> 
 
     <tr> 
 
      <td>John</td> 
 
      <td>Doe</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>Mary</td> 
 
      <td>Moe</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>July</td> 
 
      <td>Dooley</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>July</td> 
 
      <td>Dooley</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>July</td> 
 
      <td>Dooley</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>July</td> 
 
      <td>Dooley</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
      <td>July</td> 
 
      <td>Dooley</td> 
 
      <td>[email protected]</td> 
 
     </tr> 
 
     </tbody> 
 
    </table> 
 
    </div> 
 
</div>

+0

Sorry, aber ich möchte horizontale Scroll Div und die "Wrap" haben "Display: Tabelle" Ich kann diese beiden Dinge nicht ändern –

Verwandte Themen