简体   繁体   English

使用js / jQuery / css替代!

[英]Override !important in gravity forms using js/jQuery/css?

I'm trying to override a styling in gravity webforms in wordpress which is using !important 我试图在使用!important的wordpress中覆盖重力Web表单中的样式

The code I'm trying to override is <label class="gfield_label" for="input_1_20">Street Name<span class="gfield_required">*</span></label> 我要覆盖的代码是<label class="gfield_label" for="input_1_20">Street Name<span class="gfield_required">*</span></label>

CSS for that section is; 该部分的CSS是;

.gfield_label {
  margin: 10px 0 20px 0 !important;
  font-weight: bold;
  color: #000;
  display: inline-block;
  line-height: 1.2em;
  clear: both;
}

I would be happy to override everything with the class="gfield_label" 我很乐意使用class =“ gfield_label”覆盖所有内容

I have tried the following with no success; 我尝试了以下方法,但没有成功;

one

jQuery('gfield_label').attr('style', 'margin: 15px 0 5px 0 !important;');

two

( '.gfield_label' ).each(function () {
    this.style.setProperty( 'margin', '15px', '0', '5px', '0', '!important' );
});

three

jQuery( ".gfield_label" ).css( "cssText", "margin: 15px 0 5px 0 !important;" );

four

label[for=input_1_20] .gfield_label {
    margin: 15px 0 5px 0 !important;
    }

I've tested jQuery on the site and it is working. 我已经在网站上测试了jQuery,并且它正在运行。

The custom CSS and jQ is loading at the bottom of the page, way after the links for the css files gravity forms uses. 自定义CSS和jQ将在页面底部加载,即使用CSS文件重力形式的链接之后。

Any help greatly appreciated! 任何帮助,不胜感激!

Go to the settings of the plugin and switch "output css" to "No". 转到插件的设置,然后将“输出CSS”切换为“否”。

These guys must learn how to style. 这些家伙必须学习如何设计风格。 All their !importants made me a headache 他们所有的重要因素让我头疼

You can easily override these using css by puttiing following code after <?php wp_footer(); ?> 您可以通过在<?php wp_footer(); ?>之后放置以下代码来使用CSS轻松覆盖这些内容<?php wp_footer(); ?> <?php wp_footer(); ?> in your footer.php <?php wp_footer(); ?>在您的footer.php中

<style>
label[for=input_1_20] .gfield_label {
    margin: 15px 0 5px 0 !important;
}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM