微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – span:hover在Firefox中不起作用但在Chrome中有效

我有一段代码,我在Firefox中不起作用.按钮悬停时.icon图像不会改变.它在Chrome中完美运行.

button.add-to-cart-button .button-left .icon {
  display: block;
  position: absolute;
  left: 0;/*RW 6px; */
  top: 0;/*RW  6px; */
  width: 35px;/*RW 21px; */
  height: 31px;/*RW 19px; */
  background: url(http://client4.bostonwebco.com/skin/ideal_responsive/images/custom/add_to_cart.gif) 50% 50% no-repeat;
}
button.add-to-cart-button .button-left {
  display: block;
  text-indent: -5000px;
  overflow: hidden;
  padding-left: 0px !important;/*RW  2px  */
  width: 35px !important;/*RW  30px  */
  position: relative;
  font-size: 11px;
  text-align: center;
  border: 0px;
  height: 31px;
  margin: 0px;
}
button.add-to-cart-button:hover span.button-left:hover span.icon:hover {
  background: url("http://client4.bostonwebco.com/skin/ideal_responsive/images/custom/add_to_cart-over.gif") 50% 50% no-repeat !important;
  display: block;
  border: none;
}
<div class="buttons-row">
  <button class="button main-button add-to-cart-button" type="submit" title="Add to cart">
    <span class="button-right">
      <span class="button-left">
        <span class="lbl" id="lbl_add_to_cart" onmouSEOver="javascript: lmo(this,event);">Add to cart</span>
        <span class="icon"></span>
      </span>
    </span>
  </button>
</div>

JS小提琴:http://jsfiddle.net/dKcdK/14/

解决方法

您的问题是Firefox不响应元素的悬停选择器(如果它是按钮的子节点).见 https://bugzilla.mozilla.org/show_bug.cgi?id=843003.

您可以通过附加简化CSS:将鼠标悬停在按钮上:

button.add-to-cart-button .button-left .icon {
  display: block;
  position: absolute;
  left: 0;/*RW 6px; */
  top: 0;/*RW  6px; */
  width: 35px;/*RW 21px; */
  height: 31px;/*RW 19px; */
  background: url(http://client4.bostonwebco.com/skin/ideal_responsive/images/custom/add_to_cart.gif) 50% 50% no-repeat;
}
button.add-to-cart-button .button-left {
  display: block;
  text-indent: -5000px;
  overflow: hidden;
  padding-left: 0px !important;/*RW  2px  */
  width: 35px !important;/*RW  30px  */
  position: relative;
  font-size: 11px;
  text-align: center;
  border: 0px;
  height: 31px;
  margin: 0px;
}
.add-to-cart-button:hover .icon {
  background: url("http://client4.bostonwebco.com/skin/ideal_responsive/images/custom/add_to_cart-over.gif") 50% 50% no-repeat !important;
  display: block;
  border: none;
}
<div class="buttons-row">
  <button class="button main-button add-to-cart-button" type="submit" title="Add to cart">
    <span class="button-right">
      <span class="button-left">
        <span class="lbl" id="lbl_add_to_cart">Add to cart</span>
        <span class="icon"></span>
      </span>
    </span>
  </button>
</div>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐