0

Basically, I would like vertical lines to go all the way to the top of my table, even if there is not a td in the top top of the table.

I am open to using divs or seomthing like that is if it is not too complex.

EDIT: I guess what I want are column dividers, even if there is not tds in that particular row.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>sample</title>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
        <style type="text/css">
            .sample td{border-left: 1px solid red}
        </style>
    </head>
    <body>
        <table cellspacing='0' class='sample'>
            <tr>
                <td>Test</td><td>Test</td>
            </tr>
            <tr>
                <td>Test</td><td>Test</td><td>Test</td><td>Test</td><td>Test</td>
            </tr>
            <tr>
                <td>Test</td><td>Test</td><td>Test</td><td>Test</td>
            </tr>
        </table>
    </body>
</html>

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
GC_
  • 1,673
  • 6
  • 23
  • 39
  • Uhm, by 'vertical lines' you mean cell borders? BTW, there can't be more cells in a row than in another, use colspan if you want to fill extra space avoiding writing empty – Damien Pirsy Jan 30 '11 at 17:38
  • I mean any sort of vertical lines. – GC_ Jan 30 '11 at 17:40
  • I do not want the tds to get wider. If I used colspan, it will make the tds wider. – GC_ Jan 30 '11 at 17:41
  • Where do these vertical lines come from?? anyway, I believe you should write an equal number of s if you don't want to use colspan – Damien Pirsy Jan 30 '11 at 17:49
  • How do you know which cell is missing? Taking the first row, there are 3 cells missing, which ones? 1,2,3 or 3,4,5 or whatever? Where does the table came from? – Dr.Molle Jan 30 '11 at 18:02
  • What I can't do it make the vertical lines. I am producing this HTML on the on fly. I would like to do it in one pass. I don't know ahead of time how many td the longest row will have. – GC_ Jan 30 '11 at 18:03
  • If I write the extra TDs in, that will require a second pass through the data to add the correct number of TDs. One pass to count the max length, and then a second pass to make all the columns that length. – GC_ Jan 30 '11 at 18:05
  • I guess I am hoping for a way to avoid haivng to do the second pass. – GC_ Jan 30 '11 at 18:05
  • ? Can you show the code that prints this way? – Damien Pirsy Jan 30 '11 at 18:06
  • @Dr. Molle The missing columns are always at the end. – GC_ Jan 30 '11 at 18:06
  • If you want to avoid the 2nd pass you should show us the first one :) – Dr.Molle Jan 30 '11 at 18:07
  • The first pass just splits up each row, by a delimiter and produces tds. – GC_ Jan 30 '11 at 18:09
  • However, I don't know how many occurrences of the delimiter there is. – GC_ Jan 30 '11 at 18:10
  • [bad solution] use a background image of a grid the size of your table cells, which repeats along the x axis so to fill the space where there are missing s while giving the impression of there being a cell. – Damien Pirsy Jan 30 '11 at 18:13
  • I know know the table cell size ahead of time. – GC_ Jan 30 '11 at 18:23
  • If its not possible it's not possible. – GC_ Jan 30 '11 at 18:24
  • This really is not a CSS problem I guess. I guess have to change the data, like you mentioned below. – GC_ Jan 30 '11 at 18:25
  • If you would provide HOW you fetch these datas, then we can help you better in solving this problem! Post the code that gives you this set of datas, and let's see what can be done. – Damien Pirsy Jan 30 '11 at 18:31

1 Answers1

1

Rewrite like this, is this what you are trying to achieve?

<body>
            <table cellspacing='0' class='sample'>
                <tr>
                    <td>Test</td><td>Test</td><td></td><td></td><td></td>
                </tr>
                <tr>
                    <td>Test</td><td>Test</td><td>Test</td><td>Test</td><td>Test</td>
                </tr>
                <tr>
                    <td>Test</td><td>Test</td><td>Test</td><td>Test</td><td></td>
                </tr>
            </table>
</body>
Damien Pirsy
  • 25,319
  • 8
  • 70
  • 77