Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SCSS @each Syntax Error

Featured Replies

Hi all, I am fairly to new SCSS, and trying to create 3 classes each for a set of 5 name and value pairs. It works, but the outputted css shows each class 5 times! So something is being wrongly referenced here:

$colours: (
    white: #fff,
    purple: #20123a,
    green: #39C271,
    duskblue: #000473,
    skyblue: #41B8BC
);

@each $name, $value in $colours {
    .#{$name} {
        color: $value !important;
    }
    .#{$name}-bg {
        background-color: $value !important;
    }
    .#{$name}-border {
        border-color: $value !important;
    }
}

Let me know what I am doing wrong here! Thanks

  • Author

I am aiming for the following:

.white {
    color: #fff !important;
}
.white-bg {
    background-color: #fff !important;
}
.white-border {
    border-color: #fff !important;
}

.purple {
    color: #20123a !important;
}
.purple-bg {
    background-color: #20123a !important;
}
.purple-border {
    border-color: #20123a !important;
}

etc..

Thanks

I ran your code on  https://www.sassmeister.com to see the output, and that's exactly what you get back. Maybe I'm not understanding  something?

  • Author

Ah I think my error is not coming from this bit of code... Thanks for the resource link though that will be helpful for future tests :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.