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 9239861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:05:21+00:00 2026-06-18T08:05:21+00:00

I am currently using sass to help structure my CSS. A trivial given below.

  • 0

I am currently using sass to help structure my CSS. A trivial given below.

.container {
    .list {
        .selected {
            background-image : url('highlighted.png');
        }
    }
}

However I am also using modernizr (http://modernizr.com/docs/) and want to utilise CSS3 where possible. In this example I want to test for availability of border-radius , and use border-radius rather than a background image. Therefore I need to check for the presence of borderradius class on the html element. Is it possible to achieve this using some sort of look behind? Or do I have to repeat the code again with the .borderradius class, the end result being the following :

.container {
    .list {
        .selected {
            background-image : url('highlighted.png');
        }
    }
}

.borderradius .container {
    .list {
        .selected {
            background : yellow;
            border-radius : 10px;
        }
    }
}

To me this looks messy and difficult to maintain in a large project. Does anyone have a more elegant ways of achieving this?

  • 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-18T08:05:23+00:00Added an answer on June 18, 2026 at 8:05 am

    You can reference parent selectors using the ampersand (&), like this:

    .container {
        .list {
            .selected {
                background-image : url('highlighted.png');
                .borderradius & {
                    background : yellow;
                    border-radius : 10px;
                }
            }
        }
    }
    

    Which will compile to:

    .container .list .selected { 
        background-image : url('highlighted.png');
    }
    
    .borderradius .container .list .selected {
        background : yellow;
        border-radius : 10px;
    }
    

    Check out this article, or this one for a more in-depth explanation of how useful this can be:

    …you can place a trailing ampersand (&) character at the end of your selector declaration in place of the repeating selector, and sit back and enjoy the awesomeness of Sass

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using Mindscape Web Workbench to create css from sass. I'm using an
I'm using Sass (.scss) for my current project. Following example: HTML <div class=container desc>
Currently using SASS on a website build. It is my first project using it,
For sass currently I am using sass --watch path1:path2 to compile scss file to
I am using jruby-1.6.6 with rails 3.2 currently. And I am using gem 'bootstrap-sass',
Currently using the JQuery UI autocomplete list function JQuery UI - Autocomplete . I
Currently using an enum for a list of filenames in an application for the
I'm currently using Padrino with Sass and Slim to markup a site that I'm
So I'm working on some HTML5 code using HAML and SASS. I currently have
EDIT: Achieve this approach without using @mixin and @include Currently I'm using Sass as

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.