PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Customizing Forms with CSS

  1. I'm trying to figure out how to customize my forms with css...different color background, alter lengths of the fields, custom color for the submit button, border around the form, etc. I've looked at the CSS Targeting Samples Page and numerous posts, but I don't understand where the code is residing to change it. I feel like I'm missing what must obviously be common knowledge to everyone else. Rob told me to post my question in the forum. Here it is. Sorry to sound so stupid guys, but I'm not getting it.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  2. The styles are going to be located in your theme/child theme's styles.css file in your theme folder, or within the plug-in directory itself. However, you won't want to edit the code in the plug-ins directory, because this will typically be overwritten in the event of an update to the plugin. Same goes w/ themes. That is why it's best practice to use a child theme. However, I too am having difficulty finding out how to overwrite the styles that are located in the plugin directory because I want to keep my edits independent of the pre-fab styles that come w/ the plug-in.

    I'd suggest downloading firebug for FireFox if you use that browser. It will show you all those directories by highlighting code. There are other tools, as well, but this is what I use.

    What is the best practice way to store css overwrites of built-in gravity forms styles? For instance, I want to edit:

    .gform_wrapper input[type="text"], .gform_wrapper input[type="url"], .gform_wrapper input[type="email"], .gform_wrapper input[type="tel"], .gform_wrapper input[type="number"], .gform_wrapper input[type="password"] {
    font-family: inherit;
    font-size: 11px;
    letter-spacing: normal;
    outline-style: none;
    padding: 2px 0;
    }

    in the forms.css file, but I'm not sure where to put this. Normally, I would put the new/revised style in my styles.css file in my child theme so there are no complications w/ future updates. Please advise.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  3. So I thought about this, and I belive that if I take these styles and apply it to my child theme's styles.css file, simply dropping the ".gform_wrapper" from the listed classes, then declare the style edits I want, it should override gravity form's built in styles.

    URLdr, to clarify a little more what I was talking about w/ finding the style sheets, go to your server by ftp or your localhost if you are running WP locally, and look for the themes folder in your wp directory. Once you find the theme that you are currently using, if you open that folder, the styles.css of file should reside in there.

    If you haven't set up a child theme, there is a great article, here: http://codex.wordpress.org/Child_Themes

    I would suggest setting one of these up if you haven't. This will allow you to keep your styles from being overwritten in the future when updating either wordpress to the next version, or your plugins.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  4. :( Okay, it looks like my idea of dropping the ".gform_wrapper" from the list of classes isn't working. The styles are still being overwritten by gravity form's built in styles.

    So back to square one—how do users override form styling built in to the gravity forms plug-in w/o directly editing the plug in styles that are in gf's plugin directory?

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  5. David Peralty

    You do put it where you've mentioned, but anything you want overridden needs the !important declaration.

    .gform_wrapper { background: red !important; } should work where previous attempts to override have not.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  6. Can you post a link to your form?

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  7. Rob, I'll try David's suggestion and then try to get a link up first chance I get. Thanks for getting back to me on this. I'll keep this solution in mind when editing style markup originating from the GF plugin directory.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  8. Oh, and as far as David's suggestion, do I need to declare "!important" following every style value, or can I just do it at the end of my declaration block before closing the brackets?

    i.e. selector { property: value !important; property: value !important; }
    vs. selector { property: value; property: value !important; }

    ?

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  9. David Peralty

    For each style value you want to override. You can also turn off Gravity Forms CSS output if you want to start a little more from scratch. Depends on what will take you less work to integrate the way you want. This is a main setting in Gravity Forms.

    Posted 12 years ago on Thursday June 7, 2012 | Permalink
  10. OK. So I figured out how to add the changes to the child theme's style.css file from a video at WebDesign.com on Gravity Forms. I've done some simple things, but I want to place the form on top of an image to get a more customized look. I'm trying to figure out how to control the placement of the fields and the margins. I'm playing with two forms at http://173.254.52.96/~gmcontra/services/bathrooms/ one in a right side widget and one across the main part of the page. I'm really trying to achieve something that looks like the form on this page http://bathroom.ciacounters.com/ or the popup forms at http://pippity.com/ only I don't want to use popups.

    Posted 12 years ago on Friday June 8, 2012 | Permalink
  11. Let's take this one form at a time - first of all you can't have two of the same form on a single page because neither will submit correctly. So you'll want to make a new form or even duplicate the one form and replace it if you want that on the same page.

    I see the background you've placed is 500px tall. Do you plan on your form being that tall? You can always add a height of 500px to that form wrapper. Also, instead of adding the background to .gform_wrapper you would be better off applying it to the ID insted: #gform_wrapper_1.

    Each form has it's own unique wrapper ID. This comes in handy when you only want to show a background on an individual form. By applying the background to the .gform_wrapper class, it will apply that background to every single form that you place on your site, which I'm venturing to guess isn't what you would want to do.

    You can add padding declarations to push the fields away from the edge of the wrapper as well. How versed in CSS are you?

    Posted 12 years ago on Friday June 8, 2012 | Permalink
  12. Again, if you look at my previous comments and visit the links, you can see what I'm trying to achieve. I never had any plan to put two forms on the same page, I was just playing with the layout and code to see what they would look like. For a right column form, if you look at the bathrooms.ciacounters.com link that I provided, I would say that form is every bit of 500px, maybe more. I don't want to copy that form, but the general size and layout is what I'm looking for. I've tried various padding declarations and nothing works. I'm obviously not doing something properly. CSS...enough knowledge to get myself in trouble but not enough to get this form to look like what I want.

    Posted 12 years ago on Monday June 11, 2012 | Permalink
  13. I figured out most of what I wanted to do by watching several hours of CSS and Gravity Forms videos. I do have one problem that I can't figure out. How do I increase the width on the text input boxes. I am using the medium length. How can I make them a bit longer?

    Posted 12 years ago on Friday June 15, 2012 | Permalink
  14. This should do the trick for you:

    [css]
    .gform_widget .gform_wrapper input[type="text"], .gform_widget .gform_wrapper input[type="url"], .gform_widget .gform_wrapper input[type="email"], .gform_widget .gform_wrapper input[type="tel"], .gform_widget .gform_wrapper input[type="number"], .gform_widget .gform_wrapper input[type="password"] {
    width: 90% !important;
    }

    This group of selectors will target only the inputs within the widget area.

    Posted 12 years ago on Friday June 15, 2012 | Permalink
  15. No Rob. That didn't work. It didn't do a thing. Do I need to change from medium length to small or large too?

    Posted 12 years ago on Friday June 15, 2012 | Permalink
  16. I edited that snippet and added an !important tag to it. That will do the trick for you. Screenshot

    Posted 12 years ago on Friday June 15, 2012 | Permalink
  17. Awesome! Thank you!!

    Posted 12 years ago on Friday June 15, 2012 | Permalink