Search code examples
htmlcsswordpressmailchimp

CSS styles not applied to Mailchimp form


I have edited the style of an embedded Mailchimp form for my WP website. However, when I apply the changes to my website's footer.php and style.css, the form looks completely unstyled:

Unstyled Mailchimp form

Here's a fiddle in which you can see the style of the form I aim to apply.

You can also see the code here:

/* Changes the style of the overall form */

#mc_embed_signup {
  background: #c2cdc8;
  color: #000000;
  padding: 45px;
  text-align: center;
}


/* Styles the header text above the inputs */

#inscripcion {
  font-size: 18px;
  font: Poppins, sans-serif;
  margin: 0 0 20px;
  color: #000000;
  text-align: center;
}

#mc_embed_signup form {
  text-align: center;
  padding: 10px 0 10px 0;
}

.mc-field-group {
  display: inline-block;
}


/* positions input field horizontally */

#mc_embed_signup input.email {
  font-family: Poppins, sans-serif;
  border: none;
  padding: 15px;
  width: 50%;
  font-size: 16px;
  margin-right: 0px;
  -webkit-border-radius: 0px;
  -moz-border-radius: 0px;
  border-radius: 5px;
  color: #343434;
  background-color: #fff;
  box-sizing: border-box;
  display: inline-block;
}

#mc_embed_signup input.email:focus {
  outline-color: #FAE105;
}

#mc_embed_signup label {
  display: none;
  font-size: 16px;
  padding-bottom: 10px;
  font-weight: bold;
}

#mc_embed_signup .clear {
  display: inline-block;
}

#mc_embed_signup .button {
  background-color: #224b37;
  color: #ffffff;
  font-weight: bold;
  margin: 0 auto;
  border: none;
  padding: 15px 30px;
  border-radius: 5px;
  letter-spacing: 1px;
  font-size: 16px;
  box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  box-sizing: border-box;
  display: inline-block;
  margin-left: 2px;
  transition: all 0.23s ease-in-out 0s;
}

#mc_embed_signup .button:hover {
  cursor: pointer;
}

#mc_embed_signup div#mce-responses {
  float: left;
  top: -1.4em;
  padding: 0em .5em 0em .5em;
  overflow: hidden;
  width: 90%;
  margin: 0 5%;
  clear: both;
}

#mc_embed_signup div.response {
  margin: 1em 0;
  padding: 1em .5em .5em 0;
  font-weight: bold;
  float: left;
  top: -1.5em;
  z-index: 1;
  width: 80%;
}

#mc_embed_signup #mce-error-response {
  display: none;
}

#mc_embed_signup #mce-success-response {
  color: #529214;
  display: none;
}

#mc_embed_signup label.error {
  display: block;
  float: none;
  width: auto;
  margin-left: 1.05em;
  text-align: left;
  padding: .5em 0;
}

@media (max-width: 768px) {
  #mc_embed_signup input.email {
    width: 100%;
    margin-bottom: 5px;
  }
  #mc_embed_signup .clear {
    display: block;
    width: 100%;
  }
  #mc_embed_signup .button {
    width: 100%;
    margin: 0;
  }
}
<div id="mc_embed_signup">
  <form action="https://imthemoisturizer.us19.list-manage.com/subscribe/post?u=13cc95dc908756ea974c0f4fb&amp;id=78f2b1b6c1" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
      <div id="inscripcion">¿Quieres recibir todos mis posts? ⦙ Do you want to receive my posts?</div>
      <input type="email" value="" "style=background:#FFFFFF;" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email" required>
      <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
      <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_13cc95dc908756ea974c0f4fb_78f2b1b6c1" tabindex="-1" value=""></div>
      <div class="clear"><input type="submit" value="OK!" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
    </div>
  </form>
</div>

What's wrong with this code? Something must be blocking all styles, but I can't see what.

Thanks a lot in advance.


Solution

  • For some reason, if I included the HTML on footer.php and the CSS on style.css, the styles didn't properly load and the form had an awful appearance.

    Perhaps this isn't a neat or clean solution, but it works and now my Mailchimp form is properly styled. I simply included the styles right at the beginning of the div for the form and now they appear smoothly. I did it with this code, included on footer.php:

    <!-- Begin Mailchimp Signup Form -->
    <div id="mc_embed_signup">
    <style>
    /* Changes the style of the overall form */
    #mc_embed_signup {
        background: #c2cdc8;
        color: #000000;
        padding: 45px;
            text-align: center;
    }
       
      /* Styles the header text above the inputs */
    #inscripcion {
        font-size: 16px;
        font: Poppins,sans-serif;
        font-weight: 600;
        margin: 0 0 20px;
        color: #000000;
        text-align: center;
    }
    
    #mc_embed_signup form {
      text-align: center;
      padding: 10px 0 10px 0;
    }
    .mc-field-group {
      display: inline-block; 
    } /* positions input field horizontally */
    
    #mc_embed_signup input.email {
     font-family: Poppins,sans-serif;
      border: none;
      padding: 15px;
      width: 50%;
      font-size: 14px;
      margin-right: 5px;
      -webkit-border-radius: 0px;
      -moz-border-radius: 0px;
      border-radius: 5px;
      color: #343434;
      background-color: #fff;
      box-sizing: border-box;
      display: inline-block; 
    }
    
    #mc_embed_signup input.email:focus {
      outline-color: #FAE105;
    }
    #mc_embed_signup label {
      display: none;
      font-size: 16px;
      padding-bottom: 10px;
      font-weight: bold;
    }
    
    #mc_embed_signup .clear {
      display: inline-block;
    }
    
    #mc_embed_signup .button {
      background-color: #224b37;
      color: #ffffff;
      font: Poppins, sans-serif;
      font-weight: bold;
      margin: 0 auto;
      border: none;
      padding: 0 30px;
      border-radius: 5px;
      letter-spacing: 1px;
      font-size: 14px;
      box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
      cursor: pointer;
      box-sizing: border-box;
      display: inline-block;
      margin-left: 2px;
      transition: all 0.23s ease-in-out 0s;
    }
    #mc_embed_signup .button:hover {
      cursor: pointer;
    }
    #mc_embed_signup div#mce-responses {
      float: left;
      top: -1.4em;
      padding: 0em .5em 0em .5em;
      overflow: hidden;
      width: 90%;
      margin: 0 5%;
      clear: both;
    }
    #mc_embed_signup div.response {
      margin: 1em 0;
      padding: 1em .5em .5em 0;
      font-weight: bold;
      float: left;
      top: -1.5em;
      z-index: 1;
      width: 80%;
    }
    #mc_embed_signup #mce-error-response {
      display: none;
    }
    #mc_embed_signup #mce-success-response {
      color: #529214;
      display: none;
    }
    #mc_embed_signup label.error {
      display: block;
      float: none;
      width: auto;
      margin-left: 1.05em;
      text-align: left;
      padding: .5em 0;
    }
    @media (max-width: 768px) {
      #mc_embed_signup input.email {
          width: 100%;
          margin-bottom: 5px;
      }
      #mc_embed_signup .clear {
          display: block;
          width: 100%;
      }
      #mc_embed_signup .button {
          width: 100%;
          margin: 0; 
      }
    }
    </style>
    <form action="HERE GOES THE LINK TO YOUR MAILCHIMP FORM" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
        <div id="mc_embed_signup_scroll">
        <div id="inscripcion">¿Quieres recibir todos mis posts? ⦙ Do you want to receive my posts?</div>
        <input type="email" value="" "style=background:#FFFFFF;" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email" required>
        <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
       <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_13cc95dc908756ea974c0f4fb_78f2b1b6c1" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="OK!" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
        </div>
    </form>
    </div>
    
    <!--End mc_embed_signup-->
    

    Change it so that it adapts to your needs and preferences and it should work, although I can't guarantee that it's a clean solution.