Is it possible to show the total number of elements in a css content property?

I use the following css to display the step counter:

:before { content: "step " counter(fieldsets); counter-increment: fieldsets; /* Some more css */ } 

But I was wondering if it is possible to display the total number of elements, for example:

 :before { content: "step " counter(fieldsets) " of " total_number_of_fieldsets; counter-increment: fieldsets /* Some more css */ } 

I would like it to be a pure css solution, is this possible?

+6
source share
2 answers

If you have something else that calculates the total_number_of_fieldsets counter in CSS, this is not possible.

See this script: http://jsfiddle.net/EawLA/

You can show the total: after

Please note that this will not work in IE <9 since pseudo-elements are not supported

+1
source

CSS cannot validate the DOM or use variables, so it cannot pull up this information.

0
source

Source: https://habr.com/ru/post/924292/


All Articles