1

I am using the following CSS code to generate a baseline background on my website during development:

html { 
    background-image: url(http://basehold.it/i/24/777777);
}

I would like to pass a SASS variable of $base-line-height into the URL, so it works like this:

html { 
    background-image: url(http://basehold.it/i/$base-line-height/777777);
}

But I keep getting an error when compiling. Is there a way I can do this?

Thanks

Mike

Mike Harrison
  • 1,020
  • 2
  • 15
  • 42
  • @cimmanon marking a question as duplicate without a link to the original question is the most non-constructive thing one can do – Kevvv Mar 07 '19 at 18:14

2 Answers2

6

Use Interpolation:

html { 
    background-image: url(http://basehold.it/i/#{$base-line-height}/777777);
}
sbeliv01
  • 11,550
  • 2
  • 23
  • 24
1

You can do it by using single or double quotes:

html { 
    background-image: url('http://basehold.it/i/'+$base-line-height+'/777777');
}
fanfavorite
  • 5,128
  • 1
  • 31
  • 58