【发布时间】:2021-01-12 13:51:45
【问题描述】:
我有这 2 个样式组件
export const Icon = styled.svg`
width: 8px;
height: 8px;
background: black;
`
export const Dots = styled.div`
border: 2px solid green !imporant;
height: 30px;
background: white;
width: 16px;
height: 16px;
border: solid 1px #d2d2d2;
border-radius: 20px;
top: 25px;
position: relative;
${Icon}: hover {
background:black;
}
}
`
我想在这个 div 的悬停上显示Icon,但我不明白为什么它不起作用,
请问有什么建议吗?
【问题讨论】:
-
在上面的代码中
hover被应用到Icon而不是div。 -
我试过这样但没用
&:hover { background-color: blue; ${Icon}; }@AntonBakinowsky