×
Clear all filters including search bar
Valeri Tandilashvili's Sass Notes
.accordion {
max-width: 600px;
&__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
&--open {
display: block;
}
}
}This will generate the following regular CSS:.accordion {
max-width: 600px;
}
.accordion__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
}
.accordion__copy--open {
display: block;
}live-sass-compiler extension can generate either compressed or expanded version of .css files.
Configuration for expanded version:"liveSassCompile.settings.formats": [
{
"format": "expanded",
"extensionName": ".css",
"savePath": "/css/"
}
]
Configuration for compressed version:"liveSassCompile.settings.formats": [
{
"format": "compressed",
"extensionName": ".min.css",
"savePath": "/dist/css/"
}
].alert {
// The parent selector can be used to add pseudo-classes to the outer
// selector.
&:hover {
font-weight: bold;
}
// It can also be used to style the outer selector in a certain context, such
// as a body set to use a right-to-left language.
[dir=rtl] & {
margin-left: 0;
margin-right: 10px;
}
// You can even use it as an argument to pseudo-class selectors.
:not(&) {
opacity: 0.8;
}
}This will generate the following regular CSS:.alert:hover {
font-weight: bold;
}
[dir=rtl] .alert {
margin-left: 0;
margin-right: 10px;
}
:not(.alert) {
opacity: 0.8;
}.btn-a {
display: inline-block;
padding: 10px;
}
.btn-b {
@extend .btn-a;
background-color: black;
}Result in regular CSS:.btn-a, .btn-b {
display: inline-block;
padding: 10px;
}
.btn-b {
background-color: black;
}$spaceamounts: (1, 2, 3, 4, 5);
@each $space in $spaceamounts {
.m-#{$space} {
margin: #{$space}rem;
}
}$sizes: 40px, 50px, 80px;
@each $size in $sizes {
.icon-#{$size} {
font-size: $size;
height: $size;
width: $size;
}
}// set text color based on bg
@function set-text-color($color) {
@if (lightness($color) > 70) {
@return #333;
} @else {
@return #fff;
}
}
// set bg color & text color
@mixin set-background($color) {
background-color: $color;
color: set-text-color($color);
}
Use the mixin - "set-background"h1 {
@include set-background($primary-color);
}
Changing bg-color effect on text-color: https://youtu.be/nu5mdN2JIwM?t=2333@function set-text-color($color) {
@if (lightness($color) > 70) {
@return #333;
} @else {
@return #fff;
}
}Calling the function - "set-text-color":h1 {
background-color: $primary-color;
color: set-text-color($primary-color);
}$primary-color: blue;
$secondary-color: lightblue;And then we can import the partial into style.scss:@import 'config';