I'd like to use a font character (e.g. from font-awesome) as a background-image of an input element.
<style>
#id {
background-image: content('\f2d3'); /* content instead of url() */
background-position: right center;
}
</style>
<input id="test" />
My guess is that I'll either save the character as an image or use the pseudo-element :after with content and adequate positioning to achieve this. Just wanted to see if there are better solutions. Like would it be possible to access the character in SVG and use inline SVG as content?
Update:
I made a part solution with SVG (see https://jsfiddle.net/92h52e65/4/) but that still has the problem of using the correct font.
<style>
#input1 {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="30px" height="20px"><text x="5" y="15" font-family="FontAwesome">x</text></svg>');
background-position: right center;
background-repeat: no-repeat no-repeat;
}
</style>
<input id="input1" placeholder="insert some text here" size="30" required />
For this to work in IE and FF I had to use base64-encoding instead of utf8. I left the utf8 here to make it more readable.