[英]Styled Components cannot set :hover properties
export const WatchVideoButtonWrapper = styled.div` position: absolute; bottom: 80px; right: 33px; background-color: ${(props) => props.bgColor}; color: ${(props) => props.color}; border-radius: 100px; transition: all 0.1s; cursor: pointer; fill: ${(props) => props.color}; &:hover { background-color: ${(props) => props.hoverBgColor}; color: ${(props) => props.hoverColor}; fill: ${(props) => props.hoverColor}; } `;
And I am passing the props as such:我这样传递道具:
<WatchVideoButtonWrapper bgColor={navbar_button_background_color} color={navbar_button_text_and_icon_color} hoverBgColor={navbar_button_hover_background_color} hoverColor={navbar_button_hover_text_and_icon_color} > ... </WatchVideoButtonWrapper>
Everything works except the hover state.除悬停状态外,一切正常。 I want to implement a simple css animation when the div is hovered, but using styled components.
我想在 div 悬停时实现一个简单的 css 动画,但使用样式组件。 I have referred to the documentation and it seems all I need is
&:hover {}
inside the styled component.我已经参考了文档,看来我所需要的只是
&:hover {}
在样式组件内。 SO... the styles load and the background color and text color is correct, but when hovered, the effect is not firing.所以......样式加载并且背景颜色和文本颜色是正确的,但是当悬停时,效果不会触发。
Have you tried placing it aa higher z-index ?您是否尝试将其设置为更高的 z-index ? may be there is a block in front of your element that is preventing the pointer from interacting with it ?
可能在您的元素前面有一个块阻止指针与其交互? just a first idea...
只是第一个想法...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.