1

The purpose is to apply css style to a span element using only dynamic SASS style processor and without any javascript/jQuery.

The condition for applying style should be the text inside the span.

Example:

<span>Should be green</span>
<span>Just span</span>
<span>Just span</span>
<span>Just span</span>
<span>Just span</span>
<span>Just span</span>

While researching I did not find any solution.

I know that there are ways to set it simply by using jQuery or JS, but my requirement is to find solution in sass style.

Thank's for any advice !

Sh. Pavel
  • 1,584
  • 15
  • 28

1 Answers1

1

You just add a div or class ex:- and give the css to all the span.

.demo-class span {
  display: block;
  font-size: 30px;
}
.demo-class span:nth-of-type(1) {
      color: #008000;
}
.demo-class span:nth-of-type(2) {
      color: #7a73aa;
      font-size: 20px;
}
.demo-class span:nth-of-type(3) {
      color: #ea5f72;
      font-size: 15px;
}
.demo-class span:nth-of-type(4) {
      color: #f1cb06;
}
.demo-class span:nth-of-type(5) {
      color: #7a73aa;
      font-size: 15px;
}
.demo-class span:nth-of-type(6) {
      color: #f1cb06;
}
<div class="demo-class">
  <span>Should be green</span>
  <span>Just span</span>
  <span>Just span</span>
  <span>Just span</span>
  <span>Just span</span>
  <span>Just span</span>
</div>
Ankit Jaiswal
  • 274
  • 2
  • 8