Nested Sibling Selectors in SASS
Let's look at how to add different selectors in SASS when nesting, selecting elements by relationship. See examples.
Example
Child selector:
styles.scssdiv {
> p {
color: red;
}
}
Compilation result:
styles.cssdiv > p {
color: red;
}
Example
Neighbor selector
styles.scssdiv {
+ p {
color: red;
}
}
Compilation result:
styles.cssdiv + p {
color: red;
}
Example
Related selector:
styles.scssdiv {
~ p {
color: red;
}
}
Compilation result:
styles.cssdiv ~ p {
color: red;
}
Practical tasks
Задание 1
Tell me what the result of compiling the following code will be:
styles.scssul {
color: red;
> li {
padding: 20px;
}
}
Задание 2
Tell me what the result of compiling the following code will be:
styles.scssdiv {
ul {
> li {
padding: 20px;
}
}
}