Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:42:06+00:00 2026-06-15T01:42:06+00:00

I have a SASS based site that has two subsites. They both use exactly

  • 0

I have a SASS based site that has two subsites. They both use exactly the same HTML and CSS layout, but they change some simple brand background colours.

In my SCSS files I have a lot of the following:

body.subsite-one {
  #sidebar-second #wrapper p {
    background-color: $primary-color-one;
  }
} 

body.subsite-two {
  #sidebar-second #wrapper p {
    background-color: $primary-color-two;
  }
} 

#sidebar-second {
    padding: 10px;

  #wrapper  {
    border: 1px solid #000;

    p {
      font-size: 17px;
      /* etc... */
    }

  }

} 

Rather than declare the custom colours outside of the rest of the nesting, which quickly gets unweildy and messy, I’d like to do something like:

#sidebar-second {
    padding: 10px;

  #wrapper  {
    border: 1px solid #000;

    p {
      font-size: 17px;
      background-color: $primary-color-($subsite);
    }

  }

} 

My question therefore: Is there anyway I can set a variable, like $subsite above, that is changed by parent classes/id chains?

(NB: I can only have the subsite class set on the body, it’s not available on any other tag.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:42:08+00:00Added an answer on June 15, 2026 at 1:42 am

    The simplest solution is to just use the parent selector:

    #sidebar-second {
      padding: 10px;
      #wrapper  {
        border: 1px solid #000;
        p {
          font-size: 17px;
          .subsite-one & { background-color: $primary-color-1; }
          .subsite-two & { background-color: $primary-color-2; }
        }
      }
    }
    

    If you have a longer list of sub-sites, you could automate that:

    $subsites      : one  two     three   four   five;
    $primary-colors: red  orange  yellow  green  blue;
    
    #sidebar-second {
      padding: 10px;
      #wrapper  {
        border: 1px solid #000;
        p {
          font-size: 17px;
          @each $site in $subsites {
            $index: index($subsites,$site);
            .subsite-#{$site} & { background-color: nth($primary-colors,$index); }
          }
        }
      }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use sass --watch scss:css to have Sass automatically create CSS files (and put
Just have read sass changelog and found out that FSSM (the gem that had
I have been trying to build my own gradient mixin in SASS based on
I have researched SASS and Blueprint seperately, and think I understand how they work,
Say I have a placeholder selector in Sass. Within that selector I write some
Is it possible to access an HTML attribute value in SASS? I have a
I have a simple sinatra app that uses haml and sass for the views.
I'm attempting to use SASS on a development server I have at home. I'm
I am using Rails 3.1 and want to have a Sass variable (or other
Have deployed numerous report parts which reference the same view however one of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.