I think CSS is the wrong thing for this. Yes, using CSS you can create many shapes, but there are limitations, and in any case, drawing shapes using CSS is a little hacked, even when it's just a simple triangle.
Instead of CSS, I would suggest SVG - appropriate tools for this work.
SVG is a graphic format for vector graphics that can be embedded in the site and can be created or modified using Javascript directly on the site. Changing the color and shape of a simple polygon is about as simple as with SVG.
Another advantage of using SVG is that it is vectorial, it is scalable, so you can display it in any size.
The only side of SVG is that it is not supported by older versions of IE (IE8 and earlier). However, these browsers support an alternative language called VML, and there are several good Javascript libraries that will work with them, allowing you to fully integrate with multiple browsers. One that I would recommend is Raphael.js .
So, a tiny (and very simple) bit of Javascript code, not a very dirty CSS bit. It seems to me a winner.
source share