如何在悬停时定位 scss 中的后缀
How to target suffixes in scss at hover
我正在使用 SCSS 开发一个 nextJS 项目,我在将 child 悬停和聚焦时遇到问题:
.accordion {
max-width: 600px;
margin: 4rem auto;
width: 90%;
font-family: "Raleway", sans-serif;
background: #f4f4f4;
&__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
color: gray;
line-height: 1.6;
font-size: 14px;
font-weight: 500;
&--open {
display: block;
}
}
&:hover {
// How to target &__copy?
&__copy {
// code
}
}
}
如果我理解正确的话——你的目标是在 on/hovering 超过 它的 parent [=13= 时将一些代码应用到 .accordion__copy
].
如果是这样,应该执行以下操作:
&:hover > & {
// How to target &__copy?
&__copy {
// code
}
}
如果您的目标是在将鼠标悬停在 child 本身 上时瞄准 child,那么这应该可以解决它:
&__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
color: gray;
line-height: 1.6;
font-size: 14px;
font-weight: 500;
&--open {
display: block;
}
&:hover {
// code
}
}
我正在使用 SCSS 开发一个 nextJS 项目,我在将 child 悬停和聚焦时遇到问题:
.accordion {
max-width: 600px;
margin: 4rem auto;
width: 90%;
font-family: "Raleway", sans-serif;
background: #f4f4f4;
&__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
color: gray;
line-height: 1.6;
font-size: 14px;
font-weight: 500;
&--open {
display: block;
}
}
&:hover {
// How to target &__copy?
&__copy {
// code
}
}
}
如果我理解正确的话——你的目标是在 on/hovering 超过 它的 parent [=13= 时将一些代码应用到 .accordion__copy
].
如果是这样,应该执行以下操作:
&:hover > & {
// How to target &__copy?
&__copy {
// code
}
}
如果您的目标是在将鼠标悬停在 child 本身 上时瞄准 child,那么这应该可以解决它:
&__copy {
display: none;
padding: 1rem 1.5rem 2rem 1.5rem;
color: gray;
line-height: 1.6;
font-size: 14px;
font-weight: 500;
&--open {
display: block;
}
&:hover {
// code
}
}