I am trying to create a striped star using font-awesome fa-star-o
icon like shown below. I used background-gradient to create this effect, but instead of just covering the star icon its covering the entire square space around the icon. May be what I am trying to achieve is not possible with font-awesome icons, so open to other suggestions too, but would prefer an answer with icon.
<script src="https://use.fontawesome.com/eed659c9d4.js"></script>
<style>
.fa-star-o {
color: #cbb247;
font-size: 24px;
background: repeating-linear-gradient( -45deg, #e6c84b, #e6c84b 2px, #FFF 2px, #FFF 4px);
}
</style>
<i class="fa fa-star-o"></i>
First I would consider using
em
instead ofpx
to have something more homogeneous that scale withfont-size
. Then a trick is to combine multiple gradient in order to hide the non needed part.Of course, this is more a bad hack than a generic solution as you need to do a lot of effort to correctly calculate the gradients and you won't have transparency:
Another idea using is to use
mask
. For this I will rely on the new version of Font Awesome and will consider the full start SVG to be the mask