Reputation: 518
I'm wanting to add an image in a font awesome icon. Say I have the icon-star-empty and want to fill the internal part of that start with a photo. Is that possible? I have hacked at it, but gotten anywhere really. Any help would be appreciated.
[class^="icon-"]::before,
[class*=" icon-"]::before {
font-family: FontAwesome;
font-style: normal;
display: inline-block;
text-decoration: inherit;
}
.icon-star-empty:before {
content: "\f006";
}
.iconBackground:before {
font-size: 72px;
background: -webkit-gradient(linear, left top, left bottom, from(#f00), to(#333));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
display initial;
}
Added a fiddle per request below.
Upvotes: 0
Views: 6329
Reputation: 228282
The idea I had which only works in WebKit relies on -webkit-background-clip: text
.
It also relies on there also being a solid version of the shape in question, in this case there is .icon-star
to accompany .icon-star-empty
.
http://jsfiddle.net/thirtydot/mPA8N/2/
.icon-star-empty-filled {
font-size: 150px;
position: relative;
}
.icon-star-empty-filled:before {
content: "\f005";
color: transparent;
background: url(http://placekitten.com/300/300) no-repeat;
background-size: cover;
-webkit-background-clip: text;
}
.icon-star-empty-filled:after {
content: "\f006";
color: transparent;
background: -webkit-gradient(linear, left top, left bottom, from(#f00), to(#333));
-webkit-background-clip: text;
position: absolute;
top: 0;
left: 0;
}
Upvotes: 1