SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast archive's Avatar
    Join Date
    Mar 2007
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Selective Auto numbering (based on counter)???

    So I have an xml file that I style through CSS.

    I have some elements numbered based on a css counter:

    NUM_TAG: counter(pers_cnt)

    Is there a way to number only items that have a following or preceeding NUM_TAG element???

    That is, when an NUM_TAG item appears on it's own, I want it to have no numbering.

    Thank you all guys!

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code CSS:
    NUM_TAG+*:before, *+NUM_TAG:before {
      content:counter(pers_cnt);
    }
    You'll need to look out with this, if you want it both for following and preceding NUM_TAG elements. The selectors above may give you double numbering in some instances.

    I can't think of a way to avoid that, unless you use CSS3 pseudo-classes (which ought to be supported by modern browsers that support generated content and counters):
    Code CSS:
    NUM_TAG+*::before, *+NUM_TAG:last-child::before {
      content:counter(pers_cnt);
    }
    Birnam wood is come to Dunsinane


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
  •