【问题标题】:Why :hover css is not trigged in button tag? (with firefox) [closed]为什么 :hover css 没有在按钮标签中触发? (使用 Firefox)[关闭]
【发布时间】:2015-02-06 03:43:31
【问题描述】:

我有一个具有:hover 效果的类 CSS。

我想把它放在范围内,但它不起作用:

.test
{
 background-color: blue;   
}

.test:hover
{
   background-color: red;   
}
<button><span class="test">test</span></button>
<span class="test">test</span>

编辑:其他示例:http://jsfiddle.net/zge5nzq8/2/

那么为什么以及我该怎么做呢?

编辑:它适用于 Chrome,但不适用于 FF。

【问题讨论】:

  • 当我将鼠标悬停在按钮或跨度上时,它的背景颜色变为红色。
  • 究竟是什么不起作用?
  • 用 chrome 可以工作,但不能用 FF。
  • 这是一个已经为 FF 创建的错误 -> bugzilla.mozilla.org/show_bug.cgi?id=843003
  • @Kania 所以解决方案就是耐心等待下一个版本? :s

标签: html css firefox button hover


【解决方案1】:

这在 Firefox 中对我有用:(这里小提琴 http://jsfiddle.net/2zLfsm02/

.test
{
 background-color: blue;   
}

.test:hover, button:hover span.test
{
   background-color: red;   
}

和html一样:

<button><span class="test">test</span></button>
<span class="test">test</span>

**您可能希望在我的示例中更具体地使用样式(按钮:悬停 span.test)并给该按钮一个类。

【讨论】:

  • 是的,我自己找到了这个解决方案^^
【解决方案2】:

你需要这样的东西吗?

.test
{
 background-color: blue;   
}

.test:hover
{
   background-color: red;   
}
<button class="test"><span >test</span></button>
<span class="test">test</span>

【讨论】:

  • 当然不是,我不傻^^ 我在
  • 这一定是浏览器特有的问题。我可以在问答中看到这两种情况的红色背景色!
  • 是的,它不适用于 FF...
  • 我正在使用 FF30,它对我来说很好用!
  • 我在 ubuntu 上使用 FF 34.0,它不适合我。
猜你喜欢
  • 2020-06-10
  • 2021-02-18
  • 1970-01-01
  • 1970-01-01
  • 2014-07-16
  • 2016-04-23
  • 1970-01-01
  • 2013-10-27
  • 2020-07-03
相关资源
最近更新 更多