简体   繁体   English

CSS:hover选择器不起作用-为什么?

[英]CSS :hover selector not working - why?

This is my CSS: 这是我的CSS:

.add-to-cart button.button > span:hover {
    font-size: 14px;
}

It just wont work on hover. 它只是无法悬停工作。 If I put the font-size: 14px; 如果我输入font-size: 14px; inside the selector without :hover , it works and the font size is changed, so why not on hover? 在没有:hover的选择器中,它可以工作并且更改了字体大小,那么为什么不在hover上呢?

Unfortunately I can not share the markup, is a local installation only so far. 不幸的是,我无法共享标记,仅是本地安装。

Thanks! 谢谢!

you can try to add !important to your style in order to set the priority on the other style rules: 您可以尝试在样式中添加!important,以设置其他样式规则的优先级:

.add-to-cart button.button > span:hover {
    font-size: 14px !important;
}

If it doesn't work you probably should check your selector, in this case you can try to add the style to all the span tags (just to be sure that the selector is correct): 如果它不起作用,则可能应检查选择器,在这种情况下,您可以尝试将样式添加到所有span标签中(以确保选择器正确):

span:hover {
    font-size: 14px !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM