sir_thursday
sir_thursday

Reputation: 5409

Conditional Sass Operation

Quick question-- in Sass, is it possible to get the content of an element, and based off of it, return a certain style?

For example:

<div class="number">5</div>

// CSS
.number {
  color: red;   //If content of .number > 5
  color: blue;  //If content of .number < 5
}

Sorry if this has been asked before, there are a ton of Sass/Conditional questions, and if so, I'll just delete this.

Upvotes: 0

Views: 35

Answers (1)

Ulrich Thomas Gabor
Ulrich Thomas Gabor

Reputation: 6654

Since SASS actually has to be precompiled to be converted to CSS, which works without knowledge of what HTML will be used: No, this is not possible.

You will have to use Javascript or different semantic CSS classes.

Upvotes: 1

Related Questions