SVG as background-url in SFC <style> tag
See original GitHub issueContext
Having the same issue, but instead of using the svgs in a .css file, I’m using them in the style tag of .vue files. Any work around that’ll let me keep them in there?
_Originally posted by @shmarts in https://github.com/egoist/svg-to-vue-component/issues/18#issuecomment-503520585_
Explanation
This issue was closed due to hotfix pr (#50), however this specific case is still a problem.
If you have svg-to-vue-component
installed then you are unable to use svgs within the <style>
section of a Vue single file component.
I guess a workaround in the meantime is to just import a css/sass file with the background-image.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
vue cli 3 – use background image in style tag - Stack Overflow
I used vue cli 3 and tried url('~@/assets/image.svg') but that didn't work, I don't know why. – Lying_cat. Mar 19, 2019 at ...
Read more >06: Using SVG - SVG as background-image - CSS-Tricks
SVG images can be used as background-image in CSS as well, just like PNG, JPG, or GIF. .element { background-image: url(/images/image.svg); }.
Read more >How to add SVGs with CSS (background-image)
Let's look at how to add SVGs into the CSS property background-image and how the related background properties can transform the results.
Read more >Ways to embed a Clickable SVG-Logo into Your Website
All you have to do is open the .svg logo in a text editor, and copy paste the code. In the foreignObject, we...
Read more >Inlining SVG background images in CSS with custom properties
myComponent { background-image: url('data:image/svg+xml;utf8,<svg> . ... Tagged with tinylesson frontend development css svgs background ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Raigasm you could also do it this way: https://vue-svg-loader.js.org/faq.html#how-to-use-both-inline-and-external-svgs
Like @franciscolourenco said you juste have to put
And your css gonna look like