CSS background url SVG fill color not working (not base64) when compiling from SASS [duplicate] Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!SVG data image not working on Firefox or Chrome 72+When to use IMG vs. CSS background-image?XPointers in SVGSVG viewBox to VML coordorigin/coordsizeCSS opacity only to background color, not the text on it?SVG fill color transparency / alpha?Fill SVG path with a background-image without knowing height&widthHow to change color of SVG image using CSS (jQuery SVG image replacement)?Change color of data url embedded SVG imageCanvg conversion - weird behavior when using a fill urlHow use image/svg+xml in JMeter

How long after the last departure shall the airport stay open for an emergency return?

Map material from china not allowed to leave the country

What to do with someone that cheated their way through university and a PhD program?

With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space

Did the Roman Empire have penal colonies?

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

What is the ongoing value of the Kanban board to the developers as opposed to management

The art of proof summarizing. Are there known rules, or is it a purely common sense matter?

Is accepting an invalid credit card number a security issue?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Split coins into combinations of different denominations

Book with legacy programming code on a space ship that the main character hacks to escape

Why isn't everyone flabbergasted about Bran's "gift"?

Why is this method for solving linear equations systems using determinants works?

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Visa-free travel to the US using refugee travel document from Spain?

Israeli soda type drink

Multiple fireplaces in an apartment building?

Second order approximation of the loss function (Deep learning book, 7.33)

Could moose/elk survive in the Amazon forest?

Would reducing the reference voltage of an ADC have any effect on accuracy?

What is this word supposed to be?

Mistake in years of experience in resume?

Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?



CSS background url SVG fill color not working (not base64) when compiling from SASS [duplicate]



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!SVG data image not working on Firefox or Chrome 72+When to use IMG vs. CSS background-image?XPointers in SVGSVG viewBox to VML coordorigin/coordsizeCSS opacity only to background color, not the text on it?SVG fill color transparency / alpha?Fill SVG path with a background-image without knowing height&widthHow to change color of SVG image using CSS (jQuery SVG image replacement)?Change color of data url embedded SVG imageCanvg conversion - weird behavior when using a fill urlHow use image/svg+xml in JMeter



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1
















This question already has an answer here:



  • SVG data image not working on Firefox or Chrome 72+

    3 answers



I'm using SASS to generate my css and i'm trying to create a dotted repeated pattern to simulate a border-bottom on abbr tags using a background image image SVG.



I've searched deep but can't find a solution as i'm using sass to modify the fill color for specific site accents using parent class.



The fill is on the <rect ... /> element in the SVG.



This is my sass below...



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

&:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$body-color" /></svg>');
repeat: repeat;


@include accent-colors
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$accent-color" /></svg>') !important;








This is my compiled CSS and as you can see my fill colors are outputting fine.



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

ABBR:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#393e44" /></svg>');
background-repeat: repeat;

.accent-green ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#96d63d" /></svg>') !important;

.accent-blue ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#5e80f6" /></svg>') !important;

.accent-teal ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#2fb8cd" /></svg>') !important;

.accent-pink ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ff6e9e" /></svg>') !important;

.accent-purple ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ca63e5" /></svg>') !important;

.accent-orange ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#fd923a" /></svg>') !important;

.accent-red ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#e73e50" /></svg>') !important;




And when i'm viewing the element css using the inspector, there appears to be no errors and its using the correct accent class SVG background. But no fill color is showing.



enter image description here





I've upload the SVG code as an .svg file. When you zoom in you can see the fill on the SVG rect element is pink and working. The code is copied directly from Chrome's web inspector. So it's really bizarre why this does not work in the css background image attribute. Check it out below.



SVG https://a.uguu.se/ZvcDJWMpf5fl_accent-pink.svg





See this link below for an exact repo of my problem in jsfiddle using sass.



Fiddle https://jsfiddle.net/joshmoto/j8on1b9v/



If you inspect the :after element in the dom and remove the # from the rect fill color value you will see the SVG works but it's displaying black. Or check out this version where i've removed the # using a string replace function.




Fiddle https://jsfiddle.net/joshmoto/L1g5fo34/2/



The SVG works, but again black, so not working entirely.










share|improve this question















marked as duplicate by Robert Longson svg
Users with the  svg badge can single-handedly close svg questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 8:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

    – enxaneta
    Mar 9 at 7:15












  • Just encoding the # seemed to do the trick. Thanks for your comment.

    – joshmoto
    Mar 9 at 16:20

















1
















This question already has an answer here:



  • SVG data image not working on Firefox or Chrome 72+

    3 answers



I'm using SASS to generate my css and i'm trying to create a dotted repeated pattern to simulate a border-bottom on abbr tags using a background image image SVG.



I've searched deep but can't find a solution as i'm using sass to modify the fill color for specific site accents using parent class.



The fill is on the <rect ... /> element in the SVG.



This is my sass below...



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

&:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$body-color" /></svg>');
repeat: repeat;


@include accent-colors
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$accent-color" /></svg>') !important;








This is my compiled CSS and as you can see my fill colors are outputting fine.



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

ABBR:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#393e44" /></svg>');
background-repeat: repeat;

.accent-green ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#96d63d" /></svg>') !important;

.accent-blue ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#5e80f6" /></svg>') !important;

.accent-teal ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#2fb8cd" /></svg>') !important;

.accent-pink ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ff6e9e" /></svg>') !important;

.accent-purple ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ca63e5" /></svg>') !important;

.accent-orange ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#fd923a" /></svg>') !important;

.accent-red ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#e73e50" /></svg>') !important;




And when i'm viewing the element css using the inspector, there appears to be no errors and its using the correct accent class SVG background. But no fill color is showing.



enter image description here





I've upload the SVG code as an .svg file. When you zoom in you can see the fill on the SVG rect element is pink and working. The code is copied directly from Chrome's web inspector. So it's really bizarre why this does not work in the css background image attribute. Check it out below.



SVG https://a.uguu.se/ZvcDJWMpf5fl_accent-pink.svg





See this link below for an exact repo of my problem in jsfiddle using sass.



Fiddle https://jsfiddle.net/joshmoto/j8on1b9v/



If you inspect the :after element in the dom and remove the # from the rect fill color value you will see the SVG works but it's displaying black. Or check out this version where i've removed the # using a string replace function.




Fiddle https://jsfiddle.net/joshmoto/L1g5fo34/2/



The SVG works, but again black, so not working entirely.










share|improve this question















marked as duplicate by Robert Longson svg
Users with the  svg badge can single-handedly close svg questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 8:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

    – enxaneta
    Mar 9 at 7:15












  • Just encoding the # seemed to do the trick. Thanks for your comment.

    – joshmoto
    Mar 9 at 16:20













1












1








1









This question already has an answer here:



  • SVG data image not working on Firefox or Chrome 72+

    3 answers



I'm using SASS to generate my css and i'm trying to create a dotted repeated pattern to simulate a border-bottom on abbr tags using a background image image SVG.



I've searched deep but can't find a solution as i'm using sass to modify the fill color for specific site accents using parent class.



The fill is on the <rect ... /> element in the SVG.



This is my sass below...



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

&:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$body-color" /></svg>');
repeat: repeat;


@include accent-colors
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$accent-color" /></svg>') !important;








This is my compiled CSS and as you can see my fill colors are outputting fine.



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

ABBR:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#393e44" /></svg>');
background-repeat: repeat;

.accent-green ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#96d63d" /></svg>') !important;

.accent-blue ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#5e80f6" /></svg>') !important;

.accent-teal ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#2fb8cd" /></svg>') !important;

.accent-pink ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ff6e9e" /></svg>') !important;

.accent-purple ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ca63e5" /></svg>') !important;

.accent-orange ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#fd923a" /></svg>') !important;

.accent-red ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#e73e50" /></svg>') !important;




And when i'm viewing the element css using the inspector, there appears to be no errors and its using the correct accent class SVG background. But no fill color is showing.



enter image description here





I've upload the SVG code as an .svg file. When you zoom in you can see the fill on the SVG rect element is pink and working. The code is copied directly from Chrome's web inspector. So it's really bizarre why this does not work in the css background image attribute. Check it out below.



SVG https://a.uguu.se/ZvcDJWMpf5fl_accent-pink.svg





See this link below for an exact repo of my problem in jsfiddle using sass.



Fiddle https://jsfiddle.net/joshmoto/j8on1b9v/



If you inspect the :after element in the dom and remove the # from the rect fill color value you will see the SVG works but it's displaying black. Or check out this version where i've removed the # using a string replace function.




Fiddle https://jsfiddle.net/joshmoto/L1g5fo34/2/



The SVG works, but again black, so not working entirely.










share|improve this question

















This question already has an answer here:



  • SVG data image not working on Firefox or Chrome 72+

    3 answers



I'm using SASS to generate my css and i'm trying to create a dotted repeated pattern to simulate a border-bottom on abbr tags using a background image image SVG.



I've searched deep but can't find a solution as i'm using sass to modify the fill color for specific site accents using parent class.



The fill is on the <rect ... /> element in the SVG.



This is my sass below...



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

&:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$body-color" /></svg>');
repeat: repeat;


@include accent-colors
background:
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#$accent-color" /></svg>') !important;








This is my compiled CSS and as you can see my fill colors are outputting fine.



ABBR 
text-decoration: none !important;
cursor: default !important;
border: none;
position: relative;

ABBR:after
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 1px;
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#393e44" /></svg>');
background-repeat: repeat;

.accent-green ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#96d63d" /></svg>') !important;

.accent-blue ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#5e80f6" /></svg>') !important;

.accent-teal ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#2fb8cd" /></svg>') !important;

.accent-pink ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ff6e9e" /></svg>') !important;

.accent-purple ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#ca63e5" /></svg>') !important;

.accent-orange ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#fd923a" /></svg>') !important;

.accent-red ABBR:after
background-image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#e73e50" /></svg>') !important;




And when i'm viewing the element css using the inspector, there appears to be no errors and its using the correct accent class SVG background. But no fill color is showing.



enter image description here





I've upload the SVG code as an .svg file. When you zoom in you can see the fill on the SVG rect element is pink and working. The code is copied directly from Chrome's web inspector. So it's really bizarre why this does not work in the css background image attribute. Check it out below.



SVG https://a.uguu.se/ZvcDJWMpf5fl_accent-pink.svg





See this link below for an exact repo of my problem in jsfiddle using sass.



Fiddle https://jsfiddle.net/joshmoto/j8on1b9v/



If you inspect the :after element in the dom and remove the # from the rect fill color value you will see the SVG works but it's displaying black. Or check out this version where i've removed the # using a string replace function.




Fiddle https://jsfiddle.net/joshmoto/L1g5fo34/2/



The SVG works, but again black, so not working entirely.





This question already has an answer here:



  • SVG data image not working on Firefox or Chrome 72+

    3 answers







css svg sass fill






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 16:32







joshmoto

















asked Mar 9 at 4:52









joshmotojoshmoto

978414




978414




marked as duplicate by Robert Longson svg
Users with the  svg badge can single-handedly close svg questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 8:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Robert Longson svg
Users with the  svg badge can single-handedly close svg questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 8:32


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

    – enxaneta
    Mar 9 at 7:15












  • Just encoding the # seemed to do the trick. Thanks for your comment.

    – joshmoto
    Mar 9 at 16:20

















  • try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

    – enxaneta
    Mar 9 at 7:15












  • Just encoding the # seemed to do the trick. Thanks for your comment.

    – joshmoto
    Mar 9 at 16:20
















try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

– enxaneta
Mar 9 at 7:15






try to encode the image like this: background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='1'%3E%3Crect width='1' height='1' fill='%23393e44' /%3E%3C/svg%3E"); This: %23 instead of # and other replacements.

– enxaneta
Mar 9 at 7:15














Just encoding the # seemed to do the trick. Thanks for your comment.

– joshmoto
Mar 9 at 16:20





Just encoding the # seemed to do the trick. Thanks for your comment.

– joshmoto
Mar 9 at 16:20












1 Answer
1






active

oldest

votes


















2














In svg, # needs to be encoded, and replaced with %23.



So you need to create a function to do the replacement. I.E.:



@function url-encoded-color($color) 
@return '%23' + str-slice('#$color', 2, -1)



And then for svg, place it instead of variable directly:



 background: 
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#url-encoded-color($body-color)" /></svg>');
repeat: repeat;



Full example:
https://jsfiddle.net/niklaz/26Ljsmdu/3/






share|improve this answer


















  • 1





    Bingo, thank you worked a beaut.

    – joshmoto
    Mar 9 at 16:18

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














In svg, # needs to be encoded, and replaced with %23.



So you need to create a function to do the replacement. I.E.:



@function url-encoded-color($color) 
@return '%23' + str-slice('#$color', 2, -1)



And then for svg, place it instead of variable directly:



 background: 
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#url-encoded-color($body-color)" /></svg>');
repeat: repeat;



Full example:
https://jsfiddle.net/niklaz/26Ljsmdu/3/






share|improve this answer


















  • 1





    Bingo, thank you worked a beaut.

    – joshmoto
    Mar 9 at 16:18















2














In svg, # needs to be encoded, and replaced with %23.



So you need to create a function to do the replacement. I.E.:



@function url-encoded-color($color) 
@return '%23' + str-slice('#$color', 2, -1)



And then for svg, place it instead of variable directly:



 background: 
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#url-encoded-color($body-color)" /></svg>');
repeat: repeat;



Full example:
https://jsfiddle.net/niklaz/26Ljsmdu/3/






share|improve this answer


















  • 1





    Bingo, thank you worked a beaut.

    – joshmoto
    Mar 9 at 16:18













2












2








2







In svg, # needs to be encoded, and replaced with %23.



So you need to create a function to do the replacement. I.E.:



@function url-encoded-color($color) 
@return '%23' + str-slice('#$color', 2, -1)



And then for svg, place it instead of variable directly:



 background: 
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#url-encoded-color($body-color)" /></svg>');
repeat: repeat;



Full example:
https://jsfiddle.net/niklaz/26Ljsmdu/3/






share|improve this answer













In svg, # needs to be encoded, and replaced with %23.



So you need to create a function to do the replacement. I.E.:



@function url-encoded-color($color) 
@return '%23' + str-slice('#$color', 2, -1)



And then for svg, place it instead of variable directly:



 background: 
image: url('data:image/svg+xml;utf8, <svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"><rect width="1" height="1" fill="#url-encoded-color($body-color)" /></svg>');
repeat: repeat;



Full example:
https://jsfiddle.net/niklaz/26Ljsmdu/3/







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 6:31









niklazniklaz

2,07511318




2,07511318







  • 1





    Bingo, thank you worked a beaut.

    – joshmoto
    Mar 9 at 16:18












  • 1





    Bingo, thank you worked a beaut.

    – joshmoto
    Mar 9 at 16:18







1




1





Bingo, thank you worked a beaut.

– joshmoto
Mar 9 at 16:18





Bingo, thank you worked a beaut.

– joshmoto
Mar 9 at 16:18





Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved