tags:

views:

153

answers:

2

I have a table in which in one column some content is initially hidden, but appears on hover. The problem is that on hover the content then resizes that column's width and distorts the table.

How can I set the column to not resize itself without setting table layout: fixed or setting a width.

The table layout fixed causes columns to size themselves in unnatural ways, using only the first row, which is unacceptable due to the large variations in content length in different rows.

Is there a way to allow the table to size widths according to the longest column of any row, and then disallow resizing when it's hovering.

I'm using css hover to do my show hide if that's relevant. Thanks.

A: 

Hide the content using a div or a span which "covers" the column instead of hiding the actual content itself.

altCognito
Using a span wouldn't work as you wouldn't be able to adjust the height. Also using a covering div would be painful (though possible) if you are only trying to cover a portion of the contents of the column, which I think is what's being requested.
ozan
+1  A: 

Why don't you just change the opacity attribute on hover, rather than the display attribute? So to reveal the content you would change opacity from 0 to 1, and to hide it from 1 to 0.

ozan
+1 Not a bad idea either, and wouldn't require the extra non-semantic div.
altCognito
I'd use visibilty:hidden/visibility:show rather than opacity as it is more widely supported, and visibility:hidden (unlike display:none;) keeps the elements space in the layout.
wheresrhys
Ah good point wheresrhys, I'd forgotten about the 'visibility' attribute! Much better than my solution as opacity is unsupported by older versions of IE and opera. If you put that up as an answer I'll mark this one for deletion.
ozan
Thanks a lot for the suggestion, however that does create a large empty space in the middle of my table, which is problematic.... Then I can set the height to very small. HMM! Thanks folks.