代码之家  ›  专栏  ›  技术社区  ›  Steven Smith

删除或禁用其中一个wordpress小部件类

  •  0
  • Steven Smith  · 技术社区  · 7 年前

    我有一个关于Widget类布局的小问题,我有5个相同的Widget,但其中一个Widget的视频剪辑有问题,

    我研究了浏览器开发模式,发现了这个问题

    enter image description here

    <div id="shapely_home_parallax-20" class="widget shapely_home_parallax">        <section class=" border-bottom">
    
    <div class="container">
    <div class="row">
    <div class="col-sm-10 col-sm-offset-1 text-center mt30">
    <div class="">
    <div class="mb32">
    <div class="col-md-7 col-sm-6 text-center mb-xs-24">
    
    <iframe>I remove all iframe for youtube</iframe></div>
    <div class="col-md-4 col-md-offset-1 col-sm-5 col-sm-offset-1
    text-left"></p>
    <h3>User Friendly with Easy Installation</h3>
    <p>We designed our range of adaptable flood barriers with our clients in mind. With a simple installation, almost anyone can secure their home or business against floods and water damage. Thanks to the customisable width and two variations of securing mechanisms, our flood barriers will ensure your investments remain safely sealed.
    </p></div>
    </div>                              </div>
    </div>
    <!--end of row-->
    

    我试图找到一种只禁用此部分的方法

    <div class="col-sm-10 col-sm-offset-1 text-center mt30">
    

    或者变成

    <div class="text-center">
    

    但没有任何效果

    任何例子或类似的问题都会很好。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Vasim Shaikh    7 年前

    可以使用Jquery删除这些类。

    jQuery('#shapely_home_parallax-20 .mt30').removeClass("col-sm-10 col-sm-offset-1 mt30");
    

    您只需要具有唯一的div id,并引用它,就可以删除该类。

    放在哪里:

    wp_footer() 作用若并没有标签,那个么你们应该把标签放在里面。

        2
  •  0
  •   Steven Smith    7 年前

    多谢各位

    它的工作很好,但我没有把页脚文件,因为我不喜欢把任何东西放在PHP文件由于更新主题等。

    <?php
    function script_widget_CSS_remove(){ ?>
    
    <script>
    jQuery('#shapely_home_parallax-20 .mt30').removeClass("col-sm-10 col-sm-offset-1 mt30");
    </script>
    
    <?php } 
    
    add_action('wp_footer', 'script_widget_CSS_remove');