htmlcsstwitter-bootstrapcenteringmailchimp

How to center Mailchimp sign-up form div?


I've found this q&a on stack but both solutions did not work..

How do I center a mailchimp embed form in a twitter bootstrap page?

centering input in form mailchimp

What I think these questions lack is both the code for the form and style code included (see below). How can I center both the content (text) and the div itself as a whole so it's responsively centered on the page?

    <link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
    #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
    /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
       We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>

    <center>
        <div class="display:block margin:auto "id="mc_embed_signup">
    <form action="//twitter.us11.list-manage.com/subscribe/post?u=b59cd34816a376a0c58945aee&amp;id=2e74fec4e5" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
        <div id="mc_embed_signup_scroll">
        <label for="mce-EMAIL">Subscribe to our mailing list</label>
        <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" 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;"><input type="text" name="b_b59cd34816a376a0c58945aee_2e74fec4e5" tabindex="-1" value="">
            </div>
        <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
            </div>
            </div>
            </div>   
</form>
    </div>
</center>

You can see I've attempted the tags as well as altering the class within the form..

Any help is greatly appreciated :3


Solution

  • You are using bootstrap. So how about wrapping that code inside the bootstrap's grid system.

    #mc_embed_signup {
      background: #fff;
      clear: left;
      font: 14px Helvetica, Arial, sans-serif;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-3"></div>
        <div class="col-md-6">
          <center>
            <div class="display:block margin:auto " id="mc_embed_signup">
              <form action="//twitter.us11.list-manage.com/subscribe/post?u=b59cd34816a376a0c58945aee&amp;id=2e74fec4e5" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
                <div id="mc_embed_signup_scroll">
                  <label for="mce-EMAIL">Subscribe to our mailing list</label><br />
                  <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" 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;">
                    <input type="text" name="b_b59cd34816a376a0c58945aee_2e74fec4e5" tabindex="-1" value="">
                  </div>
                  <div class="clear">
                    <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
                  </div>
                </div>
              </form>
            </div>
          </center>
        </div>
        <div class="col-md-3"></div>
      </div>
    </div>