Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to += in SCSS?

Does anyone know how to += with SCSS?

Example:

.example {
    padding: 2px;
    &:hover {
        padding: current_padding + 3px; // OR
        padding+= 3px                   //... something like this
    }
}

I'm trying to get .example:hover to have 5px padding.

like image 249
kidcapital Avatar asked Jun 16 '11 21:06

kidcapital


People also ask

How do I apply for SCSS?

In order to open a SCSS account, the customer must visit the post office or bank branch and fill up the related form. The same form should be attached with KYC documents, age proof, ID proof, Address proof and cheque for deposit amount.

Is SCSS easy to learn?

Easy to learn: If you are familiar with CSS already, then you'll be glad to know that Sass actually has a similar syntax, and so you can start using it, even after this tutorial ;) Compatibility: It is compatible with all versions of CSS.

How do I enable SCSS in HTML?

Add the following to the <head> tag of your HTML file. The extension we installed will compile the SASS file index. scss into CSS and store the compiled code in a new CSS file, also called index. css .


1 Answers

I don't think there's a way to do exactly what you want to in SCSS, but you could achieve the same effect by using variables:

SCSS

.example {
    $padding: 2px;
    padding: $padding;
    &:hover {
        padding: $padding + 3px;
    }
}

Compiles to

.example { padding: 2px; }
.example:hover { padding: 5px; }

See the documentation on variables and number operations.

like image 65
Daniel Vandersluis Avatar answered Oct 17 '22 22:10

Daniel Vandersluis