【问题标题】:Override CSS background image in Wordpress plugin在 Wordpress 插件中覆盖 CSS 背景图像
【发布时间】:2014-07-08 17:47:35
【问题描述】:

我正在尝试删除 AddToAny Wordpress 插件的默认背景图像图标。正如您在下面的 URL 中看到的,蓝色图标希望被黑色齿轮取代。问题是蓝色图标是由内联样式引入的,插件中有一个 !important 声明。 :(

他们的内联代码:

.a2a_dd.addtoany_share_save {
    background: url(http://www.dlillianphotography.com/staging/wp-content/plugins/add-to-any/favicon.png) no-repeat scroll 4px 0px !important;
}

我的代码,希望嵌套/层次结构会有所帮助:

.social .row:first-of-type .addtoany_list .a2a_dd.addtoany_share_save {
    background: #fff !important;
}

感谢您的阅读。

【问题讨论】:

    标签: css wordpress plugins


    【解决方案1】:

    你可以使用 jQuery 来做到这一点

    ('.a2a_dd.addtoany_share_save').removeAttr( "style" );
    

    那么你的风格就会奏效

    【讨论】:

      【解决方案2】:

      你可以使用 .setProperty() 来做到这一点

        $(document).ready(function(){
           $('.a2a_dd.addtoany_share_save').each(function () {
              this.style.setProperty( 'background', '#fff', 'important' );
           });
        });
      

      【讨论】: