分享这个jquery背景图像的变化

时间:2012-12-19 21:11:31

标签: jquery wordpress social sharethis

<span class="stMainServices st-facebook-counter" style="background-image: url(http://w.sharethis.com/images/facebook_counter.png);">&nbsp;<img src="http://w.sharethis.com/images/check-big.png" style="position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; max-width: 19px; max-height: 19px; display: none;"></span>

我无法使用自己的图像更改背景图像(facebook_counter)。 我试图通过使用来改变它 .css(“background-image”,“url ...”)和.attr(“style”,“new style”)但也许我正在使用选择器部分错误。

我也是通过在wordpress安装中使用wp socializer获取此代码。 感谢

2 个答案:

答案 0 :(得分:0)

这是因为CSS优先级。内联样式(使用标记中的style="blah"声明)的优先级高于样式表中的项目。

您可以使用样式上的!important标记覆盖它,但this is considered bad practice

.st-facebook-counter
{
    background-image: url('someotherimage.jpg') !important;
}

答案 1 :(得分:0)

要更改背景图片,例如facebook:

默认情况下,sharet的工作原理如下:

<span class="st_facebook"></span>

我们需要将上面改为

<span class="st_facebook_custom"></span>

然后将样式添加到类中:

        .st_facebook_custom{
    background: url("http://path/to/image/file") no-repeat scroll left top transparent;
    padding:0px 16px 0 0;
} 

它应该与您需要的图像完美配合。