You can do this a few ways.
- Count the results using a server language. Send a string to each div's class, along with result set, based on a switch or condition around the count.
- Count the number of children in the parent and distribute the desired width across the children.
I think the latter is purely css. The sooner would require a server language.