Add extend/inherit and operator definitions (#28490)

* Add extend/inherit and operator definitions

* Update index.md
This commit is contained in:
James Hogan
2019-03-09 11:05:05 +00:00
committed by The Coding Aviator
parent 5b79aba887
commit eddf9063fc

View File

@ -117,8 +117,8 @@ Mixins can also take arguements. For example:
## Extends ## Extends
Sometimes youll want one selector to share the styles of another selector. The `@extend` directive works like mixins in that youre able to share snippets of code across your stylesheets. `@extend` is useful for sharing sets of related properties that get repeated in your stylesheets, such as base styles for button sets. Sometimes youll want one selector to share the styles of another selector. The `@extend` directive works like mixins in that youre able to share snippets of code across your stylesheets. `@extend` is useful for sharing sets of related properties that get repeated in your stylesheets, such as base styles for button sets.
Example: Example 1:
```css ```sass
.btn--primary { .btn--primary {
background-color: #333; background-color: #333;
border-radius: 5px; border-radius: 5px;
@ -132,5 +132,37 @@ Example:
} }
``` ```
Example 2:
```sass
%success {
background-color:green;
color:white;
}
#myDiv {
@extend %success;
font-size:10px;
}
#myOtherDiv {
@extend %success;
font-size:20px;
}
```
Both selectors(`#myDiv` and `#myOtherDiv`) will inherit properties from `%success`, while maintaining their own unique properties.
## Operators
Sass adds mathematical operators, such as +, -, *, / and % to CSS.
Example:
```
#myDiv {
height: 1920px / 480px;
width: 1080px * 2;
}
```
## Additional Resources ## Additional Resources
- [Official Sass website](https://sass-lang.com/) - [Official Sass website](https://sass-lang.com/)