Pure CSS star shape [duplicate]

Let’s break it into pieces:

The yellow borders are actually set as transparent in the final product so they don’t show. They are yellow here to show how the borders look.

As commented above, this answer shows the idea behind the basic triangle shape.

The div by itself:

<div id="star-five"></div>

Piece one

Combining the :before pseudo element is the same as this:

<div id="star-five">
    <div id="before"></div>
</div>

Piece two

Finally, combining the :after pseudo element is the same as this:

<div id="star-five">
    <div id="before"></div>

    <div id="after"></div>
</div>

Piece three

Now you overlap each element precisely using position: absolute; and rotate with transform as needed to get the final product:

Final product

Let’s visualise it!

Animation

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)