Table window layout

Discussion in 'CSS' started by aneethu449, Jan 23, 2010.

  1. #1
    Hi All,

    i want to control the table window.
    how to put horizontal scroll bat to a table window.
    i had 10 columns in the table window, so the table window width is crossing the screen, pls help

    thanks
    Neethu :confused:
     
    aneethu449, Jan 23, 2010 IP
  2. aneethu449

    aneethu449 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Any help please
     
    aneethu449, Jan 24, 2010 IP
  3. wevlop

    wevlop Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Not quote clear about your requirement.
    I suggest you write the actual table code as much you can and put it online so that we can check what you exactly want.
     
    wevlop, Jan 24, 2010 IP
  4. aneethu449

    aneethu449 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you very much.

    Actually i am using:

    <html>
    <head>
    <style type="text/css">
    table,td,th
    {
    border:1px solid black;
    }
    table
    {
    width:100%;
    }
    th
    {
    height:50px;
    }
    </style>
    </head>

    <body>
    <table>
    <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th class="savings">Savings</th>
    </tr>
    <tr>
    <td>Peter</td>
    <td>Griffin</td>
    <td>$100</td>
    </tr>
    <tr>
    <td>Lois</td>
    <td>Griffin</td>
    <td>$150</td>
    </tr>
    <tr>
    <td>Joe</td>
    <td>Swanson</td>
    <td>$300</td>
    </tr>
    <tr>
    <td>Cleveland</td>
    <td>Brown</td>
    <td>$250</td>
    </tr>
    </table>
    </body>
    </html>

    the above coding to maintain the table window.
    But in my actual application i had 10 columns, so the width of the table window crossing the screen, can we put any scroll bar to the table window to maintain the width.

    thank you very much for your response

    Neethu
     
    aneethu449, Jan 25, 2010 IP
  5. wevlop

    wevlop Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I see.

    Try giving the table a width lets say X, and if you have 10 columns, give each TD a width of X/10

    Like:

    table { width:900px; }

    td { width:90px; } // considering you want to have 10 columns fit in the available space.
     
    wevlop, Jan 25, 2010 IP
  6. aneethu449

    aneethu449 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,
    Thank you.
    as you said i did as :

    <html>
    <head>
    <style type="text/css">
    table,td,th
    {
    border:1px solid black;
    }
    table
    {
    width:810px;
    }
    th
    {
    height:50px;
    }
    </style>
    </head>

    <body>
    <table>
    <tr>
    <th>Firstname1</th>
    <th>Lastname1</th>
    <th class="savings1">Savings</th>
    <th>Firstname2</th>
    <th>Lastname2</th>
    <th class="savings2">Savings</th>
    <th>Firstname3</th>
    <th>Lastname3</th>
    <th class="savings3">Savings</th>
    </tr>
    <tr>
    <td>Peter</td>
    <td>Griffin</td>
    <td>$100</td>
    </tr>
    <tr>
    <td>Lois</td>
    <td>Griffin</td>
    <td>$150</td>
    </tr>
    <tr>
    <td>Joe</td>
    <td>Swanson</td>
    <td>$300</td>
    </tr>
    <tr>
    <td>Cleveland</td>
    <td>Brown</td>
    <td>$250</td>
    </tr>
    </table>
    </body>
    </html>


    same thing happening, i mean the width of the table exceeding the screen.
    can we put a scroll bar for table window, to maintain certain width in the screen.

    once again thanks for your reply.
     
    aneethu449, Jan 25, 2010 IP
  7. wevlop

    wevlop Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Try adding some width to the TD/TH like : td,th { width:80px; }

    I will have to ask how big is the "screen"? And by screen do you mean the entire browser window or the available space in your page?

    Not sure if you can add a scroll bar to a table. Try the first line & lets see if that helps.
     
    wevlop, Jan 25, 2010 IP
  8. aneethu449

    aneethu449 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi,

    i put that
    <style type="text/css">
    table,td,th
    {
    border:1px solid black;
    }
    table
    {
    width:810px;
    }
    td
    {
    width:80px;
    }
    th
    {
    height:50px;
    width:80px;
    }
    </style>


    even though it is same.
    please check the attachement.

    thanks
     

    Attached Files:

    aneethu449, Jan 25, 2010 IP
  9. wevlop

    wevlop Guest

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ah that's quite a bit of columns. Seems like the number of Table Headings you have won't fit into a standard window.

    I don't have an exact answer but i can only suggest to put the Headings in some other way, either vertically or in 2 tables one below another.
     
    wevlop, Jan 25, 2010 IP
  10. aneethu449

    aneethu449 Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you very much, i am trying
     
    aneethu449, Jan 25, 2010 IP