Reputation: 43
I want to replace the background-image:url(image.png)
by an Unicode character or icon like "\xxxxx" in css
How to make it?
Upvotes: 4
Views: 9589
Reputation: 13129
We could pass a SVG containing a <text>
🛸 as a data URL, like so:
body {
height: 100%;
background: #272b2d;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 100'><text y='50%'>🛠</text></svg>");
background-size: cover;
background-position: calc(50vw - 4em) -1em;
}
Upvotes: 1
Reputation: 232
How about using pseudo elements?
I suggest using
:before
width z-index: -1;
Check my exmple here: https://jsfiddle.net/oyq47zsj/
I used "A" as background, but you can use any char
Upvotes: 1