css Stars

STAR 3

STAR 4

STAR 5

STAR 6

STAR 7

STAR 8

STAR 9

STAR 10

STAR 12

STARS MADE FORM CSS TRIANGLES, which have been rotated into place using the rotation.css stylesheet.

Each star consists of the requisite number of css triangles, absolutely positioned inside a relatively-positioned container div. (The triangles may have position left and top to center them in their containers).

As with the css polygons, it can take a bit of trial and error to find the right border-width values needed to create regular stars.

The key difference between these stars and the polygons is that the rotated triangles require their transform-origin to be set:
transform-origin:50% 100%.

Setting the property with these values shifts the triangles so that they rotate around the middle of the bottom edge of their defined border-bottoms.
(Other values can create some interesting effects, however.)

Note that some of these stars could be made more simply: Star 6 could be made from two equilateral triangles, Star 9 from three equilateral triangles,
and Star 8 could be made from two squares, but I leave this exercise to the reader.

Note: This demo uses the rotation.css stylesheet.