I am trying to add a horizontal scroll on the table only if the table overflow. table
.display {
width: 100%;
display: block;
overflow-x: scroll;
white-space: nowrap;
}
<table class="display">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Date Time</th>
<th>Details</th>
<th>Details_1</th>
<th>Details_2</th>
<th>Details_3</th>
<th>Details_4</th>
</tr>
</thead>
<tbody>
<tr>
<td>53</td>
<td>Jenny</td>
<td>2009/10/09</td>
<td>Developer</td>
<td>Developer_1</td>
<td>Developer_2</td>
<td>Developer_3</td>
<td>Developer_4</td>
</tr>
</tbody>
</table>
but, I am facing a problem. When the columns decrease, the horizontal scroll still remains there and the width of the table also decreases. I only want to add the scroll when the table overflows.
divand set its width or max-width andoverflow-x: scroll;