Support » Plugin: Contact Form 7 » Custom CSS for Submit Button

  • Tyler

    (@tyleraldridge85)


    Ok, I’ve read all the other threads about this one, and I don’t get why this isn’t working.
    I am running WP 4.0 with Vantage Pro theme.

    I have the following in my “Custom CSS” file for my theme as well as in contact-form-7/includes/css/styles.css for a 3d styled button:
    .3dbutton {color:#FFFFFF;padding:0px 20px;font-size:16px;line-height:32px;border-color:#629dd2;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;text-shadow:0px 0px 0px #000000;-moz-text-shadow:0px 0px 0px #000000;-webkit-text-shadow:0px 0px 0px #000000″}

    I have <p>[submit class:3dbutton “Send Pre-Enrollment”]</p> as the last line in my contact form. The form still shows the default button style. When I go to “Inspect Element” on the button it shows <input type=”submit” value=”Send Pre-Enrollment” class=”wpcf7-form-control wpcf7-submit 3dbutton” disabled=”disabled”>. So it’s calling the class, but it still displays the default submit button?

    URL to form: http://rxaidllc.com/4tier/enroll/

    https://wordpress.org/plugins/contact-form-7/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Had a quick look at your live form using Firebug.

    Looks like a CSS Specificity issue – see CSS Specificity: Things You Should Know​​

    For your example I would have used something like the following to both improve ​Specificity and limit side-effects:

    .wpcf7  input[type="submit"] .3dbutton {​​
    ​    // add styling here
    }​

    Tyler

    (@tyleraldridge85)

    I’ve added the following into the plugin’s style.css file:

    .wpcf7 input[type="submit"]
    ​
    .3dbutton {color:#FFFFFF;padding:0px 20px;font-size:16px;line-height:32px;border-color:#629dd2;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;text-shadow:0px 0px 0px #000000;-moz-text-shadow:0px 0px 0px #000000;-webkit-text-shadow:0px 0px 0px #000000"}

    And there is still no change to submit button. Am I missing something here?

    RE: Am I missing something here?

    Looks like it.
    ​​
    The following CSS code would probably need to ​be on a single line as follows to give you increased CSS specificity:

    .wpcf7 input[type="submit"] .3dbutton {
    // add styling here
    }

    Also the code I gave was intended as general ​guidance only. You would need to use Firebug or Chrome Dev Tools to examine the HTML and CSS of your particular CF7 form in detail to create an appropriate solution.

    Finally you should not be editing the plugin’s style.css file. Any changes you make will be lost when you next update the plugin. Add via Child Theme or use custom CSS plugin.
    ​​
    See also Styling Contact Form for a general explanation of styling CF7 forms using CSS.

    Tyler

    (@tyleraldridge85)

    Okay, I have tried simplifying my code to get the right syntax, and I tried all of the following in my theme’s built in Custom CSS option (this is where I have all other CSS adjustments for my site, that work just fine), hit save and refreshed and nothing changed about the button.

    .wpcf7 input[type="submit"] .3dbutton {
    color: #1e73be
    }
    .wpcf7-submit input[type="submit"] .3dbutton {
    color: #1e73be
    }
    .wpcf7-submit .3dbutton {
    color: #1e73be
    }
    .wpcf7-submit 3dbutton {
    color: #1e73be
    }
    .3dbutton {
    color: #1e73be
    }
    .wpcf7-form-control wpcf7-submit 3dbutton {
    color: #1e73be
    }
    .wpcf7-form-control .wpcf7-submit .3dbutton {
    color: #1e73be
    }

    None of these combinations work. I don’t get why this isn’t working.
    The class being called for the button is currently “wpcf7-form-control wpcf7-submit 3dbutton”.

    Try following:

    .wpcf7 input[type=”submit”].3dbutton {
    color: #1e73be
    }

    Note: No space between input[type=”submit”] and .3dbutton which targets input[type=”submit”] of class .3dbutton within .wpcf7 class.

    Hi Tyler, maybe it would be easier for you to start over. Here’s what I did and it works just fine:

    fyi, I use both CF 7 and Mailpoet in my WordPress 4.0.1 site. You can see my forms at my site — a CF7 form is in the content area and a Mailpoet form is in the sidebar.

    I wanted to have all my submit buttons look the same for visitors across any plugins that use buttons. I also wanted to have the button button look change depending on state (hover and click). When I added Mailpoet, I added css code for the Mailpoet buttons, so it was a simple matter to just add the same class to my CF7 form code:

    <p>[submit class:wysija-submit-field "Send Message"]</p>

    The button code that I put into custom.css (my theme’s additional css file) is:

    .wysija-submit-field {
      background: #fac903;
      background-image: -webkit-linear-gradient(top, #fac903, #a86b02);
      background-image: -moz-linear-gradient(top, #fac903, #a86b02);
      background-image: -ms-linear-gradient(top, #fac903, #a86b02);
      background-image: -o-linear-gradient(top, #fac903, #a86b02);
      background-image: linear-gradient(to bottom, #fac903, #a86b02);
      -webkit-border-radius: 10;
      -moz-border-radius: 10;
      border-radius: 10px;
      font-family: Arial;
      font-size: 20px;
      font-weight:bold;
      padding: 10px 10px 10px 10px;
      border: solid #8c711f 2px;
      text-decoration: none;
    }
    .wysija-submit-field:hover {
      background: #3cb0fd;
      background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
      background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
      text-decoration: none;
    }
    .wysija-submit-field:active {
      background: #464747;
      background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
      background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
      background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
      -webkit-border-radius: 10;
      -moz-border-radius: 10;
      border-radius: 10px;
      text-decoration: underline;
    }

    That css code gives 3 different looks for a button, and I can change the words for the button right in the CF7 form, so I can use different words for different forms. The button resizes in width to fit the button text.

    I tried other methods (including putting the class into the <p>code in the CF7 form, but that didn’t work right. The above method works across all the major browser platforms.

    If you put the css code into style.css then anytime you update your theme you’ll have to re-do the custom button code. This way if I want to globally change the look of the buttons my site visitors see, I only need to edit custom.css and change the above code information (e.g., the color numbers, the radius numbers, and the decoration) for each button state.

    So to copy my method, you’d:

    1. revert your style.css to the default that comes with your theme, and also the CF7 button code
    2. add the css code I showed you above into the custom.css file (if you have one), or at the bottom of the style.css if you don’t. You can change the colors to fit your theme, and use a different class name if you want.
    3. add the class into the CF7 submit button code.

    I hope this helps you.

    Oh, and this method supersedes any button styling you might have done in CF7, so you don’t have to revert all that (unless you want to just clean things up).

    @gardnerc or to anyone who can help…

    I am using CF7 and was able to change my submit button thru custom css code, but for some reason it doesn’t carry over on a cell phone. Here is a link the site I am working on, and here is my custom css code…

    .wpcf7-form p input.wpcf7-submit:hover {
    background-color: #002b57;
    background-image: -moz-linear-gradient(center top,#000d21 0%,#001c46 100%);
    background-image: -webkit-linear-gradient(center top,#000d21 0%,#001c46 100%);
    background-image: -ms-linear-gradient(center top,#000d21 0%,#001c46 100%);
    background-image: -o-linear-gradient(center top,#000d21 0%,#001c46 100%);
    background-image: linear-gradient(center top,#000d21 0%,#001c46 100%);
    border: 1px solid #000d21;
    }

    .wpcf7-form p input.wpcf7-submit {
    background-color: #fefefe;
    background-image: -moz-linear-gradient(center top,#001c46 0%,#000d21 100%);
    background-image: -webkit-linear-gradient(center top,#001c46 0%,#000d21 100%);
    background-image: -ms-linear-gradient(center top,#001c46 0%,#000d21 100%);
    background-image: -o-linear-gradient(center top,#001c46 0%,#000d21 100%);
    background-image: linear-gradient(center top,#001c46 0%,#000d21 100%);
    border: 1px solid #000d21;
    border-radius: 5px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
    color: #ffffff !important;
    display: inline-block;
    font: 13px/43px “PTSansBold”, arial, helvetica, sans-serif;
    height: 43px;
    padding: 0 30px;
    text-align: center;
    text-shadow: 0 1px 0 #000000;
    text-transform: uppercase;
    }

    Also, can tell me how to make my CF7 text fields longer on a cell phone? Changing them thru the Generate Tag option seems to have no affect on the mobile version of my site

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom CSS for Submit Button’ is closed to new replies.