html - Custom numbering for a reversed ordered list -


how can create custom counter styles reversed ordered list:

c10. item 10 c9. item 9 c8. item 8 c7. item 7 c6. item 6 c5. item 5 c4. item 4 c3. item 3 c2. item 2 c1. item 1 

i found this link describes how achieve custom numbering in ascending order. how can modify following reverse custom numbering , apply specific listing?

<!doctype html> <html> <style> ol.cp {     counter-reset: item;     margin-left: 0;     padding-left: 0; } ol.cp li {     display: block;     margin-bottom: .5em;     margin-left: 2em; } ol.cp:before {     display: inline-block;     content: "c"counter(item)". ";     counter-increment: item;     width: 3em;     margin-left: -2em; } </style> <body> <h2>my items</h2>     <p>         <ol reversed>             <li>item 10</li>             <li>item 9</li>             <li>item 8</li>             <li>item 7</li>             <li>item 6</li>             <li>item 5</li>             <li>item 4</li>             <li>item 3</li>             <li>item 2</li>             <li>item 1</li>         </ol>     </p>     <p>         <ol class="cp" reversed>             <li>item 10</li>             <li>item 9</li>             <li>item 8</li>             <li>item 7</li>             <li>item 6</li>             <li>item 5</li>             <li>item 4</li>             <li>item 3</li>             <li>item 2</li>             <li>item 1</li>         </ol>     </p> </body>  </html> 

the result of above code illustrated in following picture. enter image description here

the solution can come with, out using js, brute force solution. if of lists under 20 or 50... how ever many of these feel writing. can match length of list , set counter value decrement counter.

example list of 10 items:

ol.cp {     counter-reset: item;     margin-left: 0;     padding-left: 0; } ol.cp li {     display: block;     margin-bottom: .5em;     margin-left: 2em; } ol.cp li:before {     display: inline-block;     content:"c"counter(item)". ";     counter-increment: item -1;     width: 3em;     margin-left: -2em; }  ol.cp li:first-child:nth-last-child(10) {     counter-reset: item 11; } 

the problem need create 1 each length want match. here 1-10 , sample - http://jsfiddle.net/ue7dg/

ol.cp li:first-child:nth-last-child(1) {     counter-reset: item 2; } ol.cp li:first-child:nth-last-child(2) {     counter-reset: item 3; } ol.cp li:first-child:nth-last-child(3) {     counter-reset: item 4; } ol.cp li:first-child:nth-last-child(4) {     counter-reset: item 5; } ol.cp li:first-child:nth-last-child(5) {     counter-reset: item 6; } ol.cp li:first-child:nth-last-child(6) {     counter-reset: item 7; } ol.cp li:first-child:nth-last-child(7) {     counter-reset: item 8; } ol.cp li:first-child:nth-last-child(8) {     counter-reset: item 9; } ol.cp li:first-child:nth-last-child(9) {     counter-reset: item 10; } ol.cp li:first-child:nth-last-child(10) {     counter-reset: item 11; } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -