PDA

View Full Version : table in a table align?


Cris79
03-27-2003, 10:55 AM
I have a problem with a table in a table.
OK, this is what I want to do:
1. The first table must to be at the center of the page and have width=21cm
2. The second table must to be in the first one width=18cm and align like this:
left-2cm; right-1cm.

This is the code: (but I want a simple solution this is to complicated)
<HTML>
<HEAD>
<TITLE></TITLE>
<style type="text/css">
table.t1{width:21cm;}
td.td2{width:18cm;}
td.td3{width:2cm;}
td.td4{width:1cm;}
table.t2{width:18cm;}
</style>
</HEAD>
<BODY>
<TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" class="t1">
<TR>
<TD class="td3">1</TD>
<TD class="td2">
<table BORDER="1" BORDERCOLOR="#FF0000" class="t2"><tr><td>text</td></tr></table>
</TD>
<TD class="td4">3</TD>
</TR>
</TABLE>
</BODY>
</HTML>

Can this be done otherwise?
TH!!!

ronaldb66
03-27-2003, 12:26 PM
If you use tables just to get everything lining up properly, I'd suggest not using any table and creating the desired effect with two nested box elements like div; setting left and right margin on the inner element should do the trick, and you can even set borders!
Before I give it a try, please let us know if this is what you're looking for, or if you have a special reason for using tables.
Also, if it's meant for screen, a width of 21 cm, or in fact any measurement in cm, might not be a very good idea. For print, it's a different story, of course.

Cris79
03-27-2003, 01:35 PM
Well, after this nasty tables I was thinking to put a button for printing the content of the table. In my mind the table was the dimension of the printed page.
Now I think it's stupid to do like this. :mad:
Is another way to print text from an html and the text to have the size that I want?

ronaldb66
03-27-2003, 01:56 PM
CSS2 offers a possibility to use different styles for different media types, like screen, print, etc. so you can define the appropriate styles for each device. I'm not up to speed with that, though, so i'd have to read up on it. :(
So: your basic concern is having the contents of a HTML page look good on paper? Establishing that will help others to offer specific suggestions. :thumbsup:

Cris79
03-27-2003, 02:18 PM
Only this page must look good on paper her purpose is to be printed just like you see the table. The border of the table must be the border of the paper.
Is silly :D but this is what I must do with this page. :o

ronaldb66
03-27-2003, 03:04 PM
If you want to avoid the media type hassle I mentioned, creating a seperate version of said page specifically for print is not such a bad idea; Webmonkey, among others, uses this approach, but the "printer friendly version" trick is used all over the web. Only drawback is, you'll have to maintain two versions of every page; usually, though, printer friendly pages are longer the screen oriented pages often combining several screen pages into one longer print page.

The idea for a printer friendly page is to lose all or nearly all imagery used for layout and design purposes, confining yourself to text, maybe some simplified images a printer can reproduce with enough quality, and apply styles geared towards getting the printed result looking good.

Since a user still has some control over the dimensions the end result is printed in (paper orientation, margin values), allowing the content to use up the available width has preference over fixed measurements: fix the margin widths if you want, and leave the rest to flow.

This, too, can be accomplished without tables, using CSS. If you're not sure how, I can try and whip up an example.

Update:

By the way, if you do want to get into media types, here's some quality reading material :D : CSS2 - Media types (http://www.w3.org/TR/REC-CSS2/media.html).

ronaldb66
03-27-2003, 03:50 PM
Ok, I couldn't sit still so I whipped up a very basic "printer friendly" page to give you an idea.
For the critics: no, it doesn't have a doctype, and no, it probably won't validate, but with any luck it will show up.
Check it out (http://www.geocities.com/ronaldb66/printpage.htm)
Change the window size to see it adapt (if i did it correctly); same should apply for print. I only looked a the print preview, but it should print 'bout the same.

brothercake
03-27-2003, 06:47 PM
Originally posted by ronaldb66
creating a seperate version of said page specifically for print is not such a bad idea
Why do that? It's so much hassle for nothing ...

<!-- all your screens are belong to me -->
<link rel="stylesheet" type="text/css" media="screen" />

<!-- all your printers are belong to me -->
<link rel="stylesheet" type="text/css" media="print" />

Easy - no extra pages, no hassle for the user; it does exactly what it says on the tin :)

Cris79
03-28-2003, 07:14 AM
Thanks for the help. I have seen the "printer friendly" page is great, yes now I know what to do. :thumbsup:

ronaldb66
03-31-2003, 08:56 AM
Brothercake,

you're right, of course... :o How 'bout browser support for the media attribute?

Mhtml
03-31-2003, 09:28 AM
Originally posted by brothercake
Why do that? It's so much hassle for nothing ...

<!-- all your screens are belong to me -->
<link rel="stylesheet" type="text/css" media="screen" />

<!-- all your printers are belong to me -->
<link rel="stylesheet" type="text/css" media="print" />

Easy - no extra pages, no hassle for the user; it does exactly what it says on the tin :)

lol ;)

Bro's always right. :)

Cris79
03-31-2003, 12:35 PM
TH !!! This is a cool forum. Since I have enter this forum I have learn a lot.

Mhtml
03-31-2003, 12:37 PM
Originally posted by Cris79
This is a cool forum.
Damn straight!