Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sass is concatenating instead of adding? [duplicate]

Tags:

I need to define a width in my SCSS code as so:

#example {   width: $currentWidth + 349 !important; } 

Where $currentWidth is defined by the loop.

However, Sass always ends up concatenating the two numbers instead of doing the arithmetic.

I have also tried:

width: #{$currentWidth + 349}px !important;

Which still results in concatenation.

I'm wondering what I'm doing wrong? I know this is incredibly basic, but I also can't seem to find good information on how Sass handles arithmetic

like image 248
waffl Avatar asked Sep 05 '13 14:09

waffl


1 Answers

Assuming $currentWidth is an integer.

SASS:

$currentWidth: 30;  #example {   width: unquote( ($currentWidth + 349) + 'px ' + !important ); } 

CSS OUTPUT:

#example {   width: 379px !important; } 

You can test it here:

http://sass-lang.com/try.html

like image 111
Kris Hollenbeck Avatar answered Oct 13 '22 13:10

Kris Hollenbeck