-2

I was wondering, if I could compare a CSS counter to a number. Basicly, what I need is a CSS alternative to PHPs if($variable = 1).

1 Answers1

-2

CSS is stupid. Too static.

It would of made sense to have:

ul li[counter=value] {

}
  • need mod function example: 4 mod 4 = 0,,,,, 8 mod 4 = 0 (for figuring out every 2nd, 3rd, 4th element etc)
  • need even/odd function
  • need greater/less then function [counter<=n]
  • possible way to evaluate two counters, and/or a difference unction (|a - b| [>|<]= n) or to figure out multiples (a/b [<|>]= n | b/a [<|>]= n)

As a counter would be treated as a property of an element and could be referenced like a selector, but the CSS people messed up big time, and didn't implement that.

A good example is to make every other paragraph hi-lighted or the 5th paragraph underlined. Or evaluate when two counters intersect each other or are an even multiple of 2 of each other.

But if CSS was dynamic in a way, it would make things more complicated to apply style sheets.

Just like how CSS is missing a function to do proper math to calculate a proper width minus border, so it does not overflow a container. Or a width to reference another property or element. Or for CSS to be able to execute/launch a javascript subroutine/event.

So the only way around the solution is to have javascript running on the html file that does the counting. And turns no features/flags on and off, so CSS can interact with it. It's not hard to get javascript to count elements and to change their attributes.

Hawken MacKay Rives
  • 1,171
  • 1
  • 16
  • 26