0
<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 来获取此代码。谢谢

4

2 回答 2

0

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

!important您可以使用样式上的标志覆盖它,但这被认为是不好的做法

.st-facebook-counter
{
    background-image: url('someotherimage.jpg') !important;
}
于 2012-12-19T21:14:27.137 回答
0

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

默认情况下,sharethis 的工作方式如下:

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

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

于 2018-05-10T06:52:31.240 回答