回答編集履歴

3

訂正

2022/06/07 10:03

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア36134

test CHANGED
@@ -67,7 +67,7 @@
67
67
 
68
68
  .button {
69
69
  $button: &;
70
- .test {
70
+ @at-root .test {
71
71
  .button {
72
72
  &__link {
73
73
  }

2

質問の変更に合わせて追記

2022/06/07 06:02

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア36134

test CHANGED
@@ -55,3 +55,39 @@
55
55
  }
56
56
  }
57
57
  ```
58
+
59
+ ---
60
+
61
+ ### 質問の変更に合わせて追記
62
+
63
+ `.test`をネストしないのであれば、もう少しすっきりするんですが……
64
+ BEM を使っているのに詳細度を002にしてしまうのはちょっと疑問があります。
65
+
66
+ ```scss
67
+
68
+ .button {
69
+ $button: &;
70
+ .test {
71
+ .button {
72
+ &__link {
73
+ }
74
+ &__text {
75
+ color: #333;
76
+ }
77
+ &__link:hover {
78
+ position: relative;
79
+ background-color: #333;
80
+ &::before {
81
+ content: "<";
82
+ }
83
+ &::after {
84
+ content: ">";
85
+ }
86
+ #{$button}__text {
87
+ color: #fff;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```

1

コメントを受けて追記

2022/06/07 03:31

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア36134

test CHANGED
@@ -22,3 +22,36 @@
22
22
  }
23
23
  }
24
24
  ```
25
+
26
+ ---
27
+
28
+ ### コメントを受けて追記
29
+
30
+ こういうことでしょうか……?
31
+
32
+ ```scss
33
+ .test {
34
+ .button {
35
+ &__link {
36
+ }
37
+ &__text {
38
+ color: #333;
39
+ }
40
+ }
41
+ }
42
+ .button {
43
+ &__link:hover {
44
+ position: relative;
45
+ background-color: #333;
46
+ &::before {
47
+ content: "<";
48
+ }
49
+ &::after {
50
+ content: ">";
51
+ }
52
+ }
53
+ &__link:hover &__text {
54
+ color: #fff;
55
+ }
56
+ }
57
+ ```