![]() |
|
|
|
#1 |
|
Easy problem:
I want to draw a 3x3 table on a a4 paper (and then print it). The table must occupy all the paper, all cells must have the same size. I _don't_ want to specify table cell size explicitly but I would like it to be done automatically. A bit more difficult: Same as before, but I want a word centered in each cell. I know that with CSS you can specify paper size but I don't know if I can solve my problem. Thanks in advance, Gianmaria Spiff |
|
|
|
|
#2 |
|
Posts: n/a
|
In article <>, "Spiff" <>
wrote: > I want to draw a 3x3 table on a a4 paper (and then print it). The table must > occupy all the paper, all cells must have the same size. Put up a PDF file. -- Kris <> (nl) |
|
|
|
#3 |
|
Posts: n/a
|
>> I want to draw a 3x3 table on a a4 paper (and then print it). The table
>> must >> occupy all the paper, all cells must have the same size. > > Put up a PDF file. Do you know if what I asked is impossibile with html and css? Thanks, S. |
|
|
|
#4 |
|
Posts: n/a
|
Spiff wrote:
> Easy problem: I suppose. > I want to draw a 3x3 table on a a4 paper (and then print it). The > table must occupy all the paper, all cells must have the same size. > I _don't_ want to specify table cell size explicitly but I would > like it to be done automatically. What is the URL of your sample? Have you set the table width to 100% ? And the three columns to 33%? Are you using a print stylesheet? > A bit more difficult: Same as before, but I want a word centered in > each cell. Do that the same as you would for the screen media. Hmm, is this a data table, or are you using tables for layout? > I know that with CSS you can specify paper size but I don't know if > I can solve my problem. Thanks in advance, Gianmaria I've never found the need to specify paper size. -- -bts -This space intentionally left blank. |
|
|
|
#5 |
|
Posts: n/a
|
>> I want to draw a 3x3 table on a a4 paper (and then print it). The
>> table must occupy all the paper, all cells must have the same size.[...] > > What is the URL of your sample? Sorry, I don't have any url. > Have you set the table width to 100% ? And the three columns to 33%? Yes. This is my stylesheet code: table { border-collapse:collapse; width: 100%; } tr { width: 33%; text-align: center;} td { border:1px solid black;} and my html code <table> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 3</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> <td>row 2, cell 3</td> </tr> <tr> <td>row 3, cell 1</td> <td>row 3, cell 2</td> <td>row 3, cell 3</td> </tr> My code partially works. The table split up the page in 3x3 cells. The table occupy all the horizontal size of the page, but not the vertical size (that's why I think I need to specify the size of the page!). > Are you using a print stylesheet? Uhm.... I only intend to print the page on the printer, so the only stylesheet I'm using is the above one. > Hmm, is this a data table, or are you using tables for layout? ahem... I don't know. My problem is that I have 9 object (words, imagine etc) that I simply want to equally distribuite on a "a4" paper. So is this a data table or a table for layout? > I've never found the need to specify paper size. If what I intend to do is possible with html than I think I need to specify the paper size. Thanks a lot, Gianmaria |
|
|
|
#6 |
|
Posts: n/a
|
Spiff wrote:
> Yes. This is my stylesheet code: > > table { border-collapse:collapse; width: 100%; } > tr { width: 33%; text-align: center;} > td { border:1px solid black;} <sigh/> table {width: 100%; height: 100%;} td {width: 33%; height: 33%; text-align: center;} There is no point in specifying a width for a td element. Why did you not simply *try* specifying height, rather than just talking about it? > If what I intend to do is possible with html than I think I need to specify > the paper size. No you don't. The piece of paper is the viewport, just like a screen is the vieport. -- Cheers Richard. |
|
|
|
#7 |
|
Posts: n/a
|
>> table { border-collapse:collapse; width: 100%; }
>> tr { width: 33%; text-align: center;} >> td { border:1px solid black;} > > <sigh/> > > table {width: 100%; height: 100%;} > td {width: 33%; height: 33%; text-align: center;} Thanks a lot for your reply. I tried your code but I'm not able to make it works. This is the complete html code I written. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <style> table { width: 100%; height: 100%; border-collapse: collapse} td { width: 33%; height:33%; text-align: center; border: 1px solid black} </style> <title>Table</title> </head> <body> <table> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 3</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> <td>row 2, cell 3</td> </tr> <tr> <td>row 3, cell 1</td> <td>row 3, cell 2</td> <td>row 3, cell 3</td> </tr> </table> </body> </html> > There is no point in specifying a width for a td element. Yes, you're definitly right. Sorry for the stupid thing I wrote. > Why did you not simply *try* specifying height, rather than just talking > about it? I'm sorry, I only read some css tutorial and try to solve my problem. >> [..]I think I need to specify the paper size. > > No you don't. The piece of paper is the viewport, just like a screen is > the > vieport. Ok! Thanks a lot for your help! S. |
|
|
|
#8 |
|
Posts: n/a
|
Spiff wrote:
> Thanks a lot for your reply. > I tried your code but I'm not able to make it works. This is the complete > html code I written. I don't think specifying a "height" of 100% for a table will actually have much effect unless the table is contained in a block element with a known height. The height of your <body> element will default to "auto", not to the size of an A4 sheet of paper. You could try specifying the size in cm, like this: table { width:100%; } td { width:33%; height:8.5cm; text-align:center; border:1px solid black } But HTML isn't really designed for this sort of thing. Someone suggested you use a PDF file instead. I think you should follow that advice. Phil -- phil [dot] ronan @ virgin [dot] net http://vzone.virgin.net/phil.ronan/ |
|
|
|
#9 |
|
Posts: n/a
|
Thanks for your msg.
> You could try specifying the size in cm, like this: > > table { width:100%; } > td { width:33%; height:8.5cm; text-align:center; border:1px solid black } The problem is that if I need to make a different table I have to calculate each time the height. But thank you anyway. > But HTML isn't really designed for this sort of thing. Someone suggested > you > use a PDF file instead. I think you should follow that advice. Yes, I'm agree. I tought also to LaTeX, but HTML is the simplest one and I wanted to be sure that was impossible with that. AnywayA friend give me this solution that works almost perfectly (there are some problem with margin). Here it is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it"> <head> <style> @media print { @page: {margin:0px} body,html { width:20cm; height:28cm;} table { width:100%; height:100%; border-collapse: collapse;} td { width:33%; border: 1px solid black; text-align:center; } } </style> <title>3x3 table in A4 table</title> </head> <body> <table> <tbody> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> <tr> <td>7</td> <td>8</td> <td>9</td> </tr> </tbody> </table> </object> </body> </html> |
|
|
|
#10 |
|
Posts: n/a
|
Spiff wrote:
> Thanks for your msg. > > > You could try specifying the size in cm, like this: Hey people: This is *not* rocket science. http://users.bigpond.net.au/rf/printpage.htm A minimal HTML page that prints a grid on the viewport. It does *not* matter what the viewport is, a computer screen or a piece of paper or a telephone. There are no nasty dimensions specified, not cm or inches or furlongs, just the browser doing what it will do if you allow it to, that is fit the page to the viewport. http://users.bigpond.net.au/rf/printpage.jpg A picture of above URL printed on a piece of A4 paper. Note that it uses the entire viewport (except for a header and a footer for the URL and stuff). If you don't want those margins then *change your browser settings* because that is where they are specified, not in the HTML. The exact same URL could be imported into, for instance, MS Word and it would print exactly the same (except for the header/footer). HTH -- Cheers Richard. |
|