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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:54:27+00:00 2026-06-09T02:54:27+00:00

The question is pretty much in the title. I don’t know if this is

  • 0

The question is pretty much in the title.

I don’t know if this is possible, and can’t seem to make it work, but I might have overlooked something (Which I hope)

This is my color choosing function mixin thingie

=colors($color)
  @if #{$color} == 0
    background: transparent
  @if #{$color} == 1
    background: #87dcec
  @if #{$color} == 2
    background: #72d856
  @if #{$color} == 3
    background: #f7e818
  @if #{$color} == 4
    background: #f75149
  @if #{$color} == 5
    background: #303030
  @if #{$color} == 6
    background: #fff1da
  @if #{$color} == 7
    background: #75430a
  @if #{$color} == 8
    background: #0e7259

And this is my @for

@for $i from 1 through 143
  li:nth-child(#{$i})
    float: left
    width: 50px
    height: 50px
    $color: #{attr(color)}
    +colors($color)

So my SASS has decided only to use the last if’s color, which is weird because I don’t even use 8 yet.

And yes, I have a attribute in html called color

  • 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-09T02:54:28+00:00Added an answer on June 9, 2026 at 2:54 am

    SASS is just extension of CSS, so you can use HTML attributes only in selectors, like so:

    .some[color] { color: $color; }  // $color is SCSS variable
    .some[color=red] { color: red; }
    

    You can not set (or get) html attributes values from within of your (S)CSS.

    But in your case you can just use a set of plain CSS classes:

    .class[color=0] { background: transparent; }
    .class[color=1] { background: #87dcec; }
    

    and so on, and just include them into your SASS styles.


    In less, when using less.js, you can get access to DOM attributes via JavaScript, see “JavaScript evaluation” in the tutorial:

    @height: `document.body.clientHeight`;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The question is pretty much in the title. But i'm trying to make a
The question is pretty much in the title, but I will elaborate. I have
The title of the question pretty much states the problem. Is it possible?
The title pretty much asks the whole question - How can I clear ONLY
The question is pretty much all in the title. Is it possible (and how?)
This question is pretty much similar to this one , but for SQL Server
The Title pretty much sums up my question. Why can't the following be done
The title pretty much precisely asks the question, but I shall repeat; When I
My question is pretty much as the title says: How can I get SD
Question pretty much says it all. You can read entity association here , but

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.