Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Sass from making quotes arround value [duplicate]

Tags:

sass

I am quiet new to Sass... I want to create some css with percentage values like:

width : 13%;

The value is the result of a sass number operation. Writing this

width : $main-width + "%"

scss code generates this:

width : "13%";

css, what is actually not working because it should be:

width : 13%;

writing

width : $main-width %;

results in

width : 13 "%"

what also leads to a non working css-rule. Is there a way to make Sass print 13% plain, with no quotes?

like image 811
philipp Avatar asked Mar 24 '12 17:03

philipp


Video Answer


2 Answers

Think of units in Sass like variables in algebra instead of just concatenating strings.

In algebra: 2x * 3 = 6x

In Sass: 13 * 1% = 13%

Use this approach to do more advanced math. 10px * 3px = 30px*px

But px*px isn't a valid CSS unit so you have to cancel one out by dividing by 1px

30px*px / 1px = 30px

Hope this helps beyond your original question.

like image 111
maxbeatty Avatar answered Oct 26 '22 14:10

maxbeatty


unquote("%") does the trick.

like image 32
philipp Avatar answered Oct 26 '22 13:10

philipp