Issue
I'm working on a nextJS project using SCSS and I have an issue to target the child at hover and focus:
.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
}
}
}
Solution
If I understood correctly — you aim to apply some code to .accordion__copy
when focusing on/hovering over its parent .accordion
.
If so, the following should do it:
&:hover > & {
// How to target &__copy?
&__copy {
// code
}
}
If your aim is to target the child when hovering over the child itself then this should fix it:
&__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
}
}
Answered By - Y H R
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.