Skip to content

Commit 920a018

Browse files
committed
Add the "Sass: Parent selector" page.
1 parent ab558ea commit 920a018

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
+++
2+
title = "Sass: Parent selector"
3+
+++
4+
5+
In Sass files, when a parent selector (`&`) is used in an inner selector, it's replaced with the corresponding outer selector.
6+
7+
For example,
8+
9+
```scss
10+
.alert {
11+
// The parent selector can be used to add pseudo-classes to the outer
12+
// selector.
13+
&:hover {
14+
font-weight: bold;
15+
}
16+
17+
// It can also be used to style the outer selector in a certain context, such
18+
// as a body set to use a right-to-left language.
19+
[dir=rtl] & {
20+
margin-left: 0;
21+
margin-right: 10px;
22+
}
23+
24+
// You can even use it as an argument to pseudo-class selectors.
25+
:not(&) {
26+
opacity: 0.8;
27+
}
28+
}
29+
```

0 commit comments

Comments
 (0)