Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assigning CSS value to SASS variable

Tags:

css

sass

Is there a way to directly assign a CSS value to a SASS variable, like this:

$var:padding: 20px/1440px * 100%;

I know that I can to this:

$padding: 20px/1440px * 100%;
padding: $padding;

But is there a way to directly assign a value in CSS to a variable? Basically to have it on a same line.

like image 936
IGRACH Avatar asked Dec 02 '25 02:12

IGRACH


1 Answers

not possible to use a variable directly, you could use a mixin instead:

@mixin pad{padding: 20px/1440px * 100%;}
.div-with-padding{@include pad;}

http://jsfiddle.net/gTsG9/

like image 184
Dax Avatar answered Dec 04 '25 01:12

Dax



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!