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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Posts
    157
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Is there a easy way of CSS styling for a sport league table?

    I am making a league table and I know how to style it with 2 different color on each row with CSS: eg light grey on row 1, dark on row 2 and so on... but is there a way using CSS to do it once rather than having to 'class' each row of the league table?

    Thanks

  • #2
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Theoretically, this is how you'd do it:
    Code:
    table tr:nth-child(2n) { background-color: grey }
    table tr:nth-child(2n-1) { background-color: aqua }
    Using CSS3 selectors. AFAIK, though, nothing supports this, so you'd have to class everything up. I'd suggest leaving in those selectors though, as they'd do something eventually, and they're not doing any harm.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    You could also just use the odd/even keywords. MSN on MacOSX supports use of these keywords (and not the linear equations):

    tr:nth-child(even) { }
    tr:nth-child(odd) { }

    But if you need reasonable support (pretty much nobody uses that browser anyway), you'll have to use classes, Javascript, or a combination of behaviors and bindings.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Posts
    157
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Oh dear, too much bothering to do that...I got to forget about it and I had another thought - I have decided to use solid bottom black border under each <td> and it looked nice, so it is done using id table once rather than having to class each row. Thanks anyway


  •  

    Posting Permissions

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