Rrptm
Rrptm

Reputation: 329

How to get font size between two ranges in SCSS?

I want to get the font size between two ranges.

$base-font: 1px;

@for $i from 1 through 100 {
  .th-#{i} {
    font-size: $base-font + $i +  px;
  }
}

When I am using class .th-30, I am not getting a font size of 30px.

Upvotes: 0

Views: 96

Answers (2)

Dan Knights
Dan Knights

Reputation: 8368

You can just remove the $base-font variable altogether. Also, you're missing a dollar sign in the selector:

@for $i from 1 through 100 {
  .th-#{$i} {
    font-size: $i +  px;
  }
}

Here's a working fiddle.

Upvotes: 1

Nisharg Shah
Nisharg Shah

Reputation: 19542

Here are some changes you need to do.

There is no need for $base-font here

$base-font: 1px;

@for $i from 1 through 100 {
  .th-#{$i} {
    font-size: #{$i}px;
  }
}

Upvotes: 2

Related Questions