Nested CSS counter does not show increment -


this question has answer here:

i trying use css counters applied series of elements , miserably fail right.

the html code simple:

<html>     <head>         <style>             body {                 counter-reset: objgen;              }             span.general:before {                 content: counter(objgen) ;                 counter-increment: objgen;             }             span.general {                 counter-reset: objesp;                 font-weight: bold;             }             span.esp:before {                 content: counter(objgen) "." counter(objesp);                 counter-increment: objesp;             }             span.esp {                 font-weight: bold;             }         </style>     </head>     <body>         <p>inputs: </p>         <p><span class="general"></span> <input type="text" value="test1"></p>         <p><span class="esp"></span> <input type="text" value="test2"></p>         <p><span class="esp"></span> <input type="text" value="test3"></p>         <p><span class="general"></span> <input type="text" value="test4"></p>         <p><span class="esp"></span> <input type="text" value="test5"></p>         <p><span class="esp"></span> <input type="text" value="test6"></p>     </body> </html> 

the objgen counter runs ok objesp never increments value: equal one. doing wrong?

is problem coming fact span class "esp" not nested within span class "general"?

comment

it seems pointed paulie_d problem structure, following html works no problem (it not possibility):

<span class="general"></span><input type="text" value="test1"> <span class="esp"></span><input type="text" value="test2"> <span class="esp"></span><input type="text" value="test3"> <span class="general"></span><input type="text" value="test1"> <span class="esp"></span><input type="text" value="test2"> <span class="esp"></span><input type="text" value="test3"> 

you using class wrong. don't need assign element span if assigned element class.

so instead of

    span.general -> .general 

that might solve problem.

            body {             counter-reset: objgen;          }         .general::before {             content: counter(objgen) ;             counter-increment: objgen;         }         .general {             counter-reset: objesp;             font-weight: bold;         }         .esp::before {             content: counter(objgen) "." counter(objesp);             counter-increment: objesp;         }         .esp {             font-weight: bold;         } 

how this?


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -