- This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
Viewing 13 posts - 1 through 13 (of 13 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hey
I use counter-increment property in css3 which give me 1,2,3,4,..etc , I wonder how to make this counter descendant like 4,3,2,1 ??
You would have to use javascript I suspect to count the number of items and then count backwards.
I doubt if there is a pure CSS way.
EDIT…there may be but you would have to know the number of items to start with.
I guess if you use ‘counter-reset’ and set it to the number of items and then set counter increment to ‘-1’.
thx Paulie_D
but i don’t the number of items
is there any method even if with PHP ?
Sorry, that about as far as I can get.
My guess is that javascript could do something for you.
You can do this through a little jQuery
count = $('element').length + 1;
$('element').each(function () {
count--;
$(this).prepend('-' + count + ' ');
});
Here is a example: CodePen Example
You could also use a reversed ordered list.
@HugoGiraudel : Are you referring to something like this?
Example. Nice find, i never knew about this, so thanks.
Reference: http://www.impressivewebs.com/reverse-ordered-lists-html5/
Yup. )
Except that there is zero browser support at the moment :)
So we’re back to JS.
EDIT: Works in Codepen / Chrome so it looks like there is some adoption.
Good find.
Safari also supports it.
I think it should be
@amid : are you referring to the js solution in the CodePen example? If so I’m not sure considering I made it as a standard unordered list and used js to manipulate a count. Technically, or semantically, I’m guessing you would use ol because it is an element you are counting, even if we give it a list-style-type: none.