html - How to remove the space created in table overflow -


whenever trying make table scroll overflow , display block css. table width getting reduced , leaves empty space. why happening? doing wrong here. table inside div.

html:

<div id="window">     <div id="tablecontainer">         <table>             <thead>                 <tr>                     <td>column 1</td>                     <td>column 2</td>                 </tr>             </thead>             <tbody>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>                 <tr>                     <td>data 1</td>                     <td>data 2</td>                 </tr>             </tbody>         </table>     </div> </div> 

css:

div{     width:500px;     height:500px;     display:block;  } table  { width:180px; height:100px; display:block; overflow:auto; border:1px solid black; } table td{     border:1px solid black;} } 

fiddle:

http://jsfiddle.net/krp7v/117/ 

html:

<div id="window"> <div id="tablecontainer">     <table>         <thead>             <tr>                 <td>column 1</td>                 <td>column 2</td>             </tr>         </thead>         <tbody>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>             <tr>                 <td>data 1</td>                 <td>data 2</td>             </tr>         </tbody>     </table> </div> 

css

#tablecontainer{    float:left;    height:100px;    display:block;    overflow-y: scroll;    float:left    }   table  {    height:100px;    display:block;    float:left; } table td{     border:1px solid black;} } 

http://jsfiddle.net/4erveak/krp7v/118/

here fix bug @ end add div , them style clear:both


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -