3

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.

1
  • No. This is what mixins are for. Commented Jun 23, 2014 at 15:45

3 Answers 3

3

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/

Sign up to request clarification or add additional context in comments.

Comments

0

no its not possible to assign directly from the variable. you have to use mixin for that.

sample :

@mixin ur_padding
{
padding:20px/1440px * 100%
}

.ur_div_here
{
@include ur_padding;
}

Comments

0

You could assign a css value like a string:

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

But I really don't know how is this going to help you. Mixin is the best way.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.