Shrink table cell to content height

380 views
Skip to first unread message

Gnarlodious

unread,
May 2, 2011, 10:34:39 PM5/2/11
to Design the Web with CSS
For some reason these cells refuse to shrink to the size of their
content:
http://Sectrum.com

CSS looks like:
table.Gnomon {margin:auto}
td.True, td.False {font-size:250%; color:#CCC; padding:0px 20px;
border:1px solid #777}

I'm a little befuddled, I tried every trick I could think of. I want
the bottom and top border to be tight against the numbers. What is
wrong?

-- Gnarlie

Mike G.

unread,
May 2, 2011, 10:56:31 PM5/2/11
to css-d...@googlegroups.com, Design the Web with CSS
Need ,ore information to be honest. Is it only a certain browser? By default, td elements are only as wide as the content that is in them unless you have a specific width set on the td element via CSS or inline attribute in the HTML.

Also, keep in mind, when I say content that is in them, if you have a column of 6 cells and the last cell's content is the widest, all of the previous cells will stretch to the same width of the 6th cell.

And in your CSS example, you have a 20px padding for both left and right, which provides additional width of the cells.

Sent from my iPad

> --
> --
> You received this because you are subscribed to the "Design the Web with CSS" at Google groups.
> To post: css-d...@googlegroups.com
> To unsubscribe: css-design-...@googlegroups.com

Gnarlodious

unread,
May 3, 2011, 12:01:18 AM5/3/11
to Design the Web with CSS
Yes, but I am trying to shrink the cells top and bottom against the
text. Notice that I have padding:0px 20px; which sets over and under
padding to 0px. What I am trying to figure out is why there is more
than zero padding.

This effect is rendering the same on Safari, Firefox and Chrome.

-- Gnarlie

Justin W Hall

unread,
May 3, 2011, 1:57:29 AM5/3/11
to css-d...@googlegroups.com

On May 3, 2011, at 12:01 AM, Gnarlodious wrote:

> Yes, but I am trying to shrink the cells top and bottom against the
> text. Notice that I have padding:0px 20px; which sets over and under
> padding to 0px. What I am trying to figure out is why there is more
> than zero padding.
>

Change your line height :)

--
Justin W. Hall
jus...@justinwhall.com
Skype: justinwhall
www.justinWhall.com


Gnarlodious

unread,
May 3, 2011, 7:48:18 AM5/3/11
to Design the Web with CSS

On May 2, 11:57 pm, Justin W Hall wrote:

> Change your line height :)

THANK YOU!

-- Gnarlie
http://Gnarlodious.com

André Moreira

unread,
May 2, 2011, 10:45:42 PM5/2/11
to css-d...@googlegroups.com
<table class="Gnomon" style="border-collapse: collapse;">

I guess this solve your problem. Sorry, I don't speak in english very well, but if you can't fix it, tell me and I will try help you.

2011/5/2 Gnarlodious <gnarl...@gmail.com>
Reply all
Reply to author
Forward
0 new messages