删除或禁用wordpress窗口小部件类之一

时间:2019-01-31 12:03:16

标签: css wordpress widget wordpress-theming

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

我浏览了浏览器开发人员模式,发现了问题 (请在屏幕截图上看到红色的高亮显示框)

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">

但没有任何作用

我只想修复一个小部件,但不是全部,我已经在wordpress的其他CSS上尝试过,但是似乎不起作用。

任何示例或类似问题都会很棒。

2 个答案:

答案 0 :(得分:1)

您可以使用Jquery删除那些类。

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

您只有唯一的div ID并带有引用,您可以删除该类。

放置位置:

您可以在wp_footer()函数之前将代码放入页脚文件中。如果没有标签,则应放在标签内。

答案 1 :(得分:0)

@Vasim

非常感谢您

它工作正常,但是我没有放入页脚文件,因为由于更新主题等原因,我不喜欢在PHP文件中放置任何内容。

我已将其放在WordPress代码段中的代码中

<?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');

工作正常