span:hover isn't working in Firefox but works in Chrome

后端 未结 2 566
执笔经年
执笔经年 2021-01-06 03:57

I have a piece of code that I doesn\'t work in Firefox. The .icon image does not change when the button is hovered. It works perfectly in Chrome.

2条回答
  •  萌比男神i
    2021-01-06 04:12

    Your issue is that Firefox does not respond to the :hover selector of an element if it is a child of a button. See https://bugzilla.mozilla.org/show_bug.cgi?id=843003.

    You can simplify your CSS by attaching :hover to the button instead:

    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;
    }

提交回复
热议问题