SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Tables with CSS?

    Hey everyone,
    This is my first post here and I'm a little confused with my tables here. Here's what I have:


    <style type="text/css">
    body, table {font-size:8pt; font-family:arial; font-color:black}
    </style>
    <table cellpadding="3">
    <tr bgcolor="#CCCCCC"><td><b>Artist</b></td><td><b>Album Name</b></td></tr>
    <tr bgcolor="#6BBDCB"><td>An Albatross</td><td>We Are the Lazer Viking</td></tr>
    <tr bgcolor="#9AD2DC"><td>Brazil</td><td>A Hostage And the Meaning of Life</td></tr>
    <tr bgcolor="#6BBDCB"><td>De Facto</td><td>Megaton Shotblast</td></tr>
    <tr bgcolor="#9AD2DC"><td>Fatal Flying Guilloteens</td><td>Split EP</td></tr>
    </table>
    I'm making a list of my CD's and the CD's I want. What I want the table to do is to alternate tr background colors automatically, so I don't have to retype everything in when I need to add another CD in the middle of the whole group. I don't think it's HTML or CSS I need to use, and I know it's possible to do this. But how? :\

  2. #2
    doing my best to help c2uk's Avatar
    Join Date
    May 2005
    Location
    Cardiff
    Posts
    1,832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off, you could use table headings for the Artist and the Album name, eg:
    Code:
    <tr>
       <th>Artist</th>
       <th>Album</th>
    </tr>
    With css, this is easy to format:
    Code:
    th {font-weight:bold; background:#CCCCCC;}
    Now your main issue. Well, I would use a database something like php / asp, with which you then also can achieve the alternate background. I'm not that experienced with it and this might not be the solution you are looking for, but I just don't know any other at the moment.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,516
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    You could just place a striped background behind the table that repeats vertically.

    e.g.

    http://www.pmob.co.uk/temp/alternate-rows-css.htm

    However that will soon break if the user resizes the text with the browser controls.

    You could also do it with javascript as follows (not my js btw):

    http://www.pmob.co.uk/temp/alternate-rows-js.htm

    Obviously a serverside solution would be similar and more robust.

    Hope it helps.

  4. #4
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're pulling from a database w/ ASP.NET I can show you how to do this in about two minutes .

    P.S.: You'll probably want to PM me if you go server side b/c I'm working with Flash at the moment and we're not getting along and I'll forget to re-check the thread.
    Ryan Butler

    Midwest Web Design


Bookmarks

Posting Permissions

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