SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to get list items to appear in reverse order

    How do you specify that the items in an ordered list should appear in reverse order. In other words, 10 should be at the top, 1 at the bottom. This is for a top ten list, if anyone is curious.

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think that can be done with CSS by itself. Try this little PHP/CSS combo:
    PHP Code:
    <style type="text/css">
    ul {list-style:none}
    </style>
    <?php
    $x
    =10;

    //Fill in your top 10 items here
    $list[10]=10;
    $list[9]=9;
    $list[8]=8;

    while(
    $x 0)
      {
      echo
    "<li>$x. ".$list[$x]."</li>";
      
    $x=$x-1;
      }
    ?>
    //Untested
    Aaron Brazell
    Technosailor



  3. #3
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm...haven't played with it, but i think you could do this in CSS2 http://www.w3.org/TR/REC-CSS2/generate.html#counters
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  4. #4
    Bangarang! Karloff's Avatar
    Join Date
    Mar 2003
    Location
    Manchester, United Kingdom
    Posts
    236
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by redux
    hmmm...haven't played with it, but i think you could do this in CSS2
    Counters can only insert content (content, and quote properties) and you can specifiy when they reset or by how much they increment. thus you could increment them by -1 I assume.

    Mind you, counters will only work in Opera as blufive has mentioned here http://www.sitepointforums.com/showt...hreadid=100351

    You can achieve re-ordering your top 10 list (on the client) with XSLT but that would make limit it to IE and Moz/NS once again. Only crossbrowser solution on the client, that I can think of, is having your 10 items in a JavaScript array and generating the list from that array. Otherwise go for a server side sorting :-P
    Karl


    I'm desperately trying to figure out why Kamikaze pilots wore helmets. - George Carlin

  5. #5
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I submitted this to the W3C. If you agree with the post, add your comment to the system by clicking reply to this post.

    http://lists.w3.org/Archives/Public/...3Mar/0112.html

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Joshua,
    Not to nit-pick, but in your e-mail you specified the <ul> tag, which should probably be the <ol> tag.

  7. #7
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    Joshua,
    Not to nit-pick, but in your e-mail you specified the <ul> tag, which should probably be the <ol> tag.
    I misstyped.


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
  •