Forum Moderators: open

Message Too Old, No Replies

css rules changes with javascript (display: block,none)

         

aguzman

6:20 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



Hi, I'm new on the list.

I'm writing some code for a form, and I have a little problem that is getting me a headache...

I'm using some fieldsets to mi form and some of their contents (most tables, but also divs) are hidden from the user until the user presses the legend(this is done by a javascript function).
The tables inside the fieldsets are centered and that remains like that, until I hide and then show the content again. When the content is hidden and I press the legend the content appears but not centered... it is aligned to the left, this only happens in firefox, in IE works fine.

I'm using a plugin for web development for firefox and I discovered that when I show the content, the table reappears maximized but the tbody remains just like it's supposed to and aligned to the left.

It is a bug that needs to be reported? has anyone had the same problem... and can it be fixed by some tricky code?

PS: I tried something with the javascript code:
Once I show the table(or div) I set the class of the table(or div) again to force ir to be centered.
But it didn't worked out..

Can anyone help me on this?
Thank you!

Ale

aguzman

7:22 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



ok, only happens with tables with auto width...
anyway.. any solution? please...

Bernard Marx

10:04 pm on Feb 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE doesn't use or respect the proper CSS display values for tables, rows etc. You simply use "block". Very convenient, but it doesn't work well in well-behaved browsers.

A workaround is to hide the elements using "display: none" in inline CSS (or via script), then show them by setting this value to an empty string, so that they revert to default.

Ref: [w3.org...]

aguzman

1:43 pm on Feb 17, 2006 (gmt 0)

10+ Year Member



Thank you so much!, that tip did the job.