【发布时间】:2017-04-21 18:46:54
【问题描述】:
在样式组件中处理悬停的最佳方法是什么。我有一个包装元素,当悬停时会显示一个按钮。
我可以在组件上实现一些状态并在悬停时切换属性,但想知道是否有更好的方法来使用 styled-cmponents 来做到这一点。
以下内容不起作用,但会是理想的:
const Wrapper = styled.div`
border-radius: 0.25rem;
overflow: hidden;
box-shadow: 0 3px 10px -3px rgba(0, 0, 0, 0.25);
&:not(:last-child) {
margin-bottom: 2rem;
}
&:hover {
.button {
display: none;
}
}
`
【问题讨论】: