悬停在StyledLink上后,如何将StyledLi :::的宽度从0%更改为90%
const StyledLink = styled(Link)`
text-decoration: none;
margin-right: 20px;
font-size: 20px;
color: grey;
transition: 0.2s;
:hover {
color: blue;
}
`
const StyledLi = styled.li`
::after {
content: "";
display: block;
width: 0%;
height: 2px;
background-color: blue;
}
`
答案 0 :(得分:0)
您可以reference other components使用样式组件。
return (
<StyledLink>
<StyledLi>
Link Text
</StyledLi>
</StyledLink>
);
const StyledLi = styled.li`
::after {
content: "";
display: block;
width: 0%;
height: 2px;
background-color: blue;
}
`;
const StyledLink = styled(Link)`
text-decoration: none;
margin-right: 20px;
font-size: 20px;
color: grey;
transition: 0.2s;
:hover {
color: blue;
${StyledLi}::after {
width: 90%;
}
}
`;