Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't change table cell width

Tags:

html

I have a table that contains another small table in a cell:

<table id="big" style='width: 100%'>
 <tr>
  ..
  <td>..</td>
  ..
 </tr>
 <tr>
  ..
  <td style='width: 75px'>
    <table style='width: 100%'>
     <tr>
      <td style='width: 33%'><select></select></td>
      <td style='width: 33%'><select></select></td>
      <td style='width: 33%'><select></select></td>
     </tr>
    </table>
  </td>
  ..
 </tr>
</table>

As you can see, I have a small table which should take the whole outer cell. This table should be divided into 1x3 cells, each containing a select combo box.

Now the inner table always takes too big width than specified, corrupting the outer table GUI.

As you can see, I have tried to limit the outer cell width in pixels, without any success.

enter image description here

like image 517
FindOut_Quran Avatar asked Dec 21 '14 07:12

FindOut_Quran


People also ask

Why can't I adjust table column width in Word?

To adjust table row and column size in Word: Click anywhere in the table. In "Table Tools" click the [Layout] tab > locate the "Cell Size" group and choose from of the following options: To fit the columns to the text (or page margins if cells are empty), click [AutoFit] > select "AutoFit Contents."

How do you unlock the width of a table in Word?

Lock or unlock the size of cells Click the Table Tools Layout tab, and do one of the following: To lock the cell size, clear the Grow to Fit Text check box. To unlock the cell size, select the Grow to Fit Text check box.

How do you increase the width of a table cell?

To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively. Just keep in mind, the usage of style attribute overrides any style set globally.


1 Answers

You need to specify fixed table layout to respect column width even if content needs more space:

table {
    table-layout: fixed;
}
like image 140
dfsq Avatar answered Oct 17 '22 18:10

dfsq