Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Table challenge

  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Table challenge

    How can I do this kind of table? The content to be in the center, but the td's background to stretch 100% of the browsers width?
    Attached Thumbnails Attached Thumbnails Table challenge-table.jpg  

  • #2
    Regular Coder Redcoder's Avatar
    Join Date
    May 2012
    Location
    /dev/null
    Posts
    333
    Thanks
    2
    Thanked 47 Times in 46 Posts
    Use CSS to position the elements.

    This is a crude example but just illustrates how to use your CSS well.

    Code:
    <style>
     .end_cells{
        width: 500px;
     }
     table{
        border-collapse: collapse;
     }
     #right_align_text{
        text-align: right;
     }
     
     </style>
    HTML

    Code:
    <table border="1" >
    <tr>
    <td id="right_align_text" class="end_cells">text</td>
    <td>text</td>
    <td >text</td>
    <td>text</td>
    <td class="end_cells"></td>
    </tr>
    <tr>
    <td id="right_align_text" class="end_cells">text</td>
    <td>text</td>
    <td >text</td>
    <td>text</td>
    <td class="end_cells"></td>
    </tr>
    
    </table>

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by iBall View Post
    I think an easier option would be to not worry about the end cells.

    You could put the table in a div, center the table within the div and put the bg in the div which by default has 100% width.
    I agree. The table would be much easier to read that way than it would with the stipes extending to the edge of the viewport, more so when the viewport is several times the width that the table needs to be.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •