0

我一直在绞尽脑汁寻找 CSS 渐变的解决方案。我打算将“添加到购物车”按钮变为橙色;它显示了黑色,它被设置为所有按钮的“默认”。

笔记:

它在 Chrome 中显示橙色的“添加到购物车”。Firefox 的工作方式有所不同。

-

代码:

.button,
#button,
#submit,
.edit{
    margin: 1em 0 1.5em 0;
    display: inline-block;
    cursor: pointer;        
    font-size: 1em;
    font-weight: normal;
    text-align: center;
    color: #fff;
    padding: 8px 25px;
    background: -moz-linear-gradient(
        top,
        #212121 0%,
        #0a0a0a);
    background: -webkit-gradient(
        linear, left top, left bottom, 
        from(#212121),
        to(#050505));
    border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border: 1px solid #000;
    -moz-box-shadow:
        0px 1px 2px rgba(000,000,000,0.3),
        inset 0px 1px 1px rgba(255,255,255,0.2);
    -webkit-box-shadow:
        0px 1px 2px rgba(000,000,000,0.3),
        inset 0px 1px 1px rgba(255,255,255,0.2);
    -webkit-transition-duration: 0.6s;
    -moz-transition-duration: 0.6s;
    -ms-transition-duration: 0.6s;
    -o-transition-duration: 0.6s;
    transition-duration: 0.6s;  
}
    .button:hover,
    #button:hover,
    #submit:hover,
    .edit:hover{
        background: -moz-linear-gradient(
            top,
            #151515 0%,
            #151515);
        background: -webkit-gradient(
            linear, left top, left bottom, 
            from(#151515),
            to(#151515));       
        -webkit-box-shadow: 0px 0px 8px 5px rgba(222, 222, 222, .95);
        -moz-box-shadow: 0px 0px 8px 5px rgba(222, 222, 222, .95);
        box-shadow: 0px 0px 8px 5px rgba(222, 222, 222, .95);
    }

    .add_to_cart_button, .single_add_to_cart_button,
    .add_to_cart_button.button, .single_add_to_cart_button.button  {
        background: -moz-linear-gradient (
            top,
            #FAB31F 0%,
            #F49100) !important;
        background: -webkit-gradient(
            linear, left top, left bottom, 
            from(#FAB31F),
            to(#F49100)) !important;
        border: 1px solid #CE7B00 !important;
    }
    .add_to_cart_button:hover, .single_add_to_cart_button:hover {
        background: -moz-linear-gradient (
            top, #F49100 0%,
            #F49100);
        background: -webkit-gradient(
            linear, left top, left bottom, 
            from(#F49100),
            to(#F49100));
        border: 1px solid #CE7B00;      
        -webkit-box-shadow: 0px 0px 8px 5px rgba(253, 213, 128, .75);
        -moz-box-shadow: 0px 0px 8px 5px rgba(253, 213, 128, .75);
        box-shadow: 0px 0px 8px 5px rgba(253, 213, 128, .75);
    }

希望这可以解决!:)

附言:

我已经测试了诸如以下的类:

  • a.add_to_cart_button
  • a.add_to_cart_button.button
  • .add_to_cart_button.button

除了 .add_to_cart_button 类的背景的“!重要”规则无济于事。

4

1 回答 1

1
background-image:-moz-linear-gradient(top, #b53b36, #9d2224);/* Firefox 3.6 */
         background-image: -webkit-gradient(linear, left top, left bottom, from( #b53b36 /*{global-active-background-start}*/), to( #9d2224 /*{global-active-background-end}*/)); /* Saf4+, Chrome */
         background-image: -webkit-linear-gradient( #b53b36 /*{global-active-background-start}*/, #9d2224 /*{global-active-background-end}*/); /* Chrome 10+, Saf5.1+ */
         background-image:     -ms-linear-gradient( #b53b36 /*{global-active-background-start}*/, #9d2224 /*{global-active-background-end}*/); /* IE10 */
         background-image:      -o-linear-gradient( #b53b36 /*{global-active-background-start}*/, #9d2224 /*{global-active-background-end}*/); /* Opera 11.10+ */
         background-image:         linear-gradient( #b53b36 /*{global-active-background-start}*/, #9d2224 /*{global-active-background-end}*/);
         filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#b53b36', endColorstr='#9d2224');/* IE6 & IE7 */
         -ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#b53b36', endColorstr='#9d2224')";/* IE8 */

您可以尝试上面的渐变代码。

于 2013-08-14T04:47:30.493 回答