Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like "+=" in SASS?

Tags:

css

sass

Is it possible to redefine a numerical attribute in SASS by increment or decrement? Consider something like this:

h1 {
    font-size: 10px;
}

h1.important {
    font-size: += 10px;
}

I know that I can work around that by defining a variable. Is it possible to do this without?

like image 697
d135-1r43 Avatar asked Feb 25 '11 12:02

d135-1r43


People also ask

Is Sass still relevant 2022?

Even though nesting is coming to CSS, the Sass version is here today and it has more features than the native CSS nesting will have. For instance, we don't need the & in Sass, making it feel more intuitive. And we can nest media queries inside selectors. And we can use nesting to generate incremental class names.

Is Sass still worth learning?

A couple of hours, there isn't really much to learn once you know mixins, includes, variables and your down with nested selectors. It's worth it alone for structuring projects with includes and nested selectors, for such a little investment it makes such a different cleaning up and improving frontend work flow.

Is Sass better than bootstrap?

"Responsiveness", "UI components" and "Consistent" are the key factors why developers consider Bootstrap; whereas "Variables", "Mixins" and "Nested rules" are the primary reasons why Sass is favored.

Is Sass better than CSS?

SASS offers a galore of features that make it a better tool than CSS for developers. Some of its major highlights are: Compatibility with CSS: One of the major features of SASS is its high compatibility with cascading style sheets, which means SASS provides support for many versions of CSS.


1 Answers

Not sure if the += works, but you could use a base variable and then add on to it in another class.

$baseFontSize: 10px

h1
  font-size: $baseFontSize


.border 
  font-size: $baseFontSize + 10px
like image 132
FreeAsInBeer Avatar answered Sep 27 '22 02:09

FreeAsInBeer