1

I have this in my SASS:

$colors: (
  primary:    #f6861f,
  secondary:  #32db64,
  danger:     #f53d3d,
  light:      #f4f4f4,
  dark:       #222
);

If I use

.menu-inner .scroll-content{
    background: $colors['primary'];
}

it doesn't work. How do I refer to primary inside my $colors array?

1 Answer 1

3

Your syntax isn't quite right - you can't use C-style associative arrays with SASS; you need to use the map-get function instead.

In your example, to access the primary colour you would do this:

.menu-inner .scroll-content {
    background: map-get($colors, primary);
}

There's some more info on SASS maps in these articles.

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

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.