My goal is to generate a html file with tables and export them into pdf.
Unfortunately I cant get the table to act like I want.
One part of the table should display a timescale with days on the lowest row, weeks,months and years are in the rows above and have a pre-calculated colspan.
Only the s for the days have a width given with CSS (style="width:..."
).
The problem is that the width is totally ignored, so fields with days from 1-9 are only half as width than the others. And in follow, because the fields above size automatically because they have no width given, their size is also wrong.
alt text http://img217.imageshack.us/img217/6617/scale1x.jpg
Heres the source that is generated: http://pastebin.com/JyiqhSzs
What we tried so far:
width=""
)Also set style="table-layout:fixed;"
for the table but that has no effect.
So I don't know how to get the table to have the width I want to have?
Using width attribute: The <td> tag has width attribute to control the width of a particular column. By assigning a numeric value to this attribute between 0 to 100 in terms of percentage(or you can use pixel format). We can restrict the column width up to that much percentage of the table's total width.
To manipulate the height or width of an entire table, place the size attribute (either "WIDTH=" or "HEIGHT=") within the <TABLE> code. To manipulate individual cells, place the size attribute within the code for that cell.
The width of the columns i.e. td in a table can be fixed very easily. This can be done by adding the width attribute in the <td> tag. If the width is not specified, the width of the column changes according to the change in the content. The specifications of width for the columns can be in pixels, or percentage.
Instead of width: 23px
use min-width: 23px
. It worked for IE8 and FireFox. I have not yet figured out a magic formula for IE7 to not narrow the single digit days (working on it). I do know that the table-layout: fixed
is not needed, and for sure will cause issues with any IE7 display that may work.
Also, if you always want them to be the same size, you might consider using em
sizing so that if text size changes, your table scales up/down with it proportionally. I don't know all your needs, but just a suggestion to look into.
Edit: More cross browser solution. IE6 and 7 need to have all the numbers in the "days" cells wrapped with a div
and then instead of styling the td
with any kind of width, style that div
with a width: 23px
not min-width: 23px
.
Is the style
attribute mistyped as stlye
in your real page, too?
Some more hints:
table-layout: fixed
after fixing the typo.div
(or some other element) to each cell and give that the width instead2ex
.td
why don't you set in the the style sheet.Example:
<tr class="days"><td>1</td><td>2</td></tr>
tr.days td {
width: 23px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With