Rui Carneiro
Rui Carneiro

Reputation: 5671

Adjust table column width to content size

Form (with firebug highlight hover the td):

example

Label column CSS:

width: auto;
padding: 0;
margin: 0;

The problem:

Why my left columns have that invisible "padding-right"? It's not possible to shrink columns to fit their content?

--EDIT--

The problem was the table itself. I defined table with "width: 100%". Removed that and the problem is gone.

Upvotes: 26

Views: 133263

Answers (3)

Nick Jameson
Nick Jameson

Reputation: 49

If you want the table to still be 100% then set one of the columns to have a width:100%; That will extend that column to fill the extra space and allow the other columns to keep their auto width :)

Upvotes: 4

Rui Carneiro
Rui Carneiro

Reputation: 5671

The problem was the table width. I had used width: 100% for the table. The table columns are adjusted automatically after removing the width tag.

Upvotes: 35

fl00r
fl00r

Reputation: 83680

maybe problem with margin?

width:auto;
padding: 0px;
margin: 0px

Upvotes: 0

Related Questions