Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent a table from shrinking into a viewport

Tags:

css

html-table

I have the following code:

table {
  border-collapse: collapse;
}

td {
  padding: 0px;
  border: 1px solid #d3d3d3;
  width: 300px;
  height: 100px;
  text-align: center;
  white-space: nowrap;
}
<table>
  <tr>
    <td>A</td>
    <td>B</td>
    <td>C</td>
  </tr>
  <tr>
    <td>D</td>
    <td>E</td>
    <td>F</td>
  </tr>
  <tr>
    <td>G</td>
    <td>H</td>
    <td>I</td>
  </tr>
</table>

When I stretch the browser so that viewport is less than 900px, table's rows are shrinked to fit into the viewport despite the fact that I set width explicitly. How can I prevent this behavior?

like image 595
Konstantin Solomatov Avatar asked Mar 16 '12 09:03

Konstantin Solomatov


1 Answers

I managed to find the answer myself:

 td {
   padding: 0px;
   border: 1px solid #d3d3d3;
   min-width: 300px;
   max-width: 300px;
   width: 300px;
   height: 100px;
   text-align: center;
   white-space: nowrap;
 }
like image 134
Konstantin Solomatov Avatar answered Oct 06 '22 01:10

Konstantin Solomatov