![]() |
[html, css, javascript] td width acting like its not there!
I have a table with some other tables inside it's cells.
I wanted the inside tables to be 100% the width of the table cells, and of course I want the table cells that contain them to be 100% of their table width (minus the padding)! However, I've noticed a very weird issue, that only occurs with firefox (and perhaps Opera but not IE7). The table cells of the outer table are less wide than the table (and I'm not counting the padding) and consequently they make the inner table less wide than I want it to be!! The table cells adjust to the automatic (defined by the content) width of the inner tables. No matter how much width="100%" I've added to the tds involved, they seem to ignore it completely! If the content is enough I get the desired result but if the content is too little they adjust to it regardless of any width definition I'm trying to apply. And if wasn't strange enough, the problem occurs only after I hide and re-show the table via javascript. Via my javascript I change the css display attribute of the table to none in order to hide it and then to block in order to show it. If I change the javasript to change the display property to 'table' and not 'block' in order to show the table it shows up properly (the cells are 100% wide) but I have problems with IE so I discarded this solution. I need to work this out via display:block for the table. Any ideas of what I could try? This issue is driving me mad :( |
Give the main <td> an attribute of width="100%" and the remaining cells a nowrap="nowrap". Post some code, I may have misunderstood.
|
the html is wrong or javascript is changing the values
as Ken suggested .. post your code |
Ok, here is the javascript:
HTML Code:
function gotocat(cat) HTML Code:
<table cellpadding="0" cellspacing="0" width="742"> Ι was able to reproduce the same problem with the least possible code so if the above is too boring to scroll through (and I understand that), try the following code, it has the same td problem although the td has a width="100%" attribute. A border has been set on the table so that you can easily see the problem if you just paste it in an html page. Note that the problem only occurs with firefox afaik. HTML Code:
<table style="display:block" border="1" width="100%"> |
I'm still not sure what it is you are trying to do ..
can you post screenshots of your problem? which browser are you testing on? version? etc |
1 Attachment(s)
I'll talk about the "stripped down to basic" problem, and not my actual one that has extra code that might tire you. If I solve this one, I'll solve the actual one I'm having.
So, this code: HTML Code:
<table style="display:block" border="1" width="100%"> Attachment 66541 Notice how the td takes the size of the content and doesn't stretch to the whole table as it should? This only happens in firefox... |
it could be an underlying bug in FF :confused:
- by default <table> and <td> are block elements not sure why you are adding "display:block" |
display:block seems out of place in the simple code above but in my actual code I use it to hide and show the table via javascript. When I want to hide it I apply a display:none via js and to show it a display:block. It's a common toggling method in js...
|
if that's the case, I suggest wrapping the <table> within a <div> and add the toggle to it
|
This is what I had thought to do in the end, but firstly I'll wait to see if I find a more "elegant" solution...
|
All times are GMT. The time now is 02:18 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|