html - 使用 Bootstrap 将电子邮件输入和按钮居中

标签 html css twitter-bootstrap

如何将我的类(class)订阅表居中 - 使用 Bootstrap

实时站点: http://185.123.96.102/~kidsdrum/moneynest.co.uk/

当前: enter image description here

预期结果: enter image description here

HTML

<div class="text-center">
    <h1 class="boldme hidden-xs hidden-sm">Wish you were taught personal finance at school? We do too</h1> 
    <div class="greenpromobox"> 
    <h2 class="boldme">Aged 20-30 and frustrated with money?</h2>

     <h3 class="boldme">Take our free <b class="jumpstarttext">Jumpstart Your Finances</b> class to<br /> secure your financial future</h3>

<script src="https://app.convertkit.com/assets/CKJS4.js?v=21"></script>
<div class="ck_form ck_naked">

  <div class="ck_form_fields">

    <div id='ck_success_msg'  style='display:none;'>
      <p>Success! </p>
    </div>

    <!--  Form starts here  -->
    <form id="ck_subscribe_form" class="ck_subscribe_form" action="https://app.convertkit.com/landing_pages/32973/subscribe" data-remote="true">
      <input type="hidden" value="{&quot;form_style&quot;:&quot;naked&quot;,&quot;embed_style&quot;:&quot;inline&quot;,&quot;embed_trigger&quot;:&quot;scroll_percentage&quot;,&quot;scroll_percentage&quot;:&quot;70&quot;,&quot;delay_seconds&quot;:&quot;10&quot;,&quot;display_position&quot;:&quot;br&quot;,&quot;display_devices&quot;:&quot;all&quot;,&quot;days_no_show&quot;:&quot;15&quot;,&quot;converted_behavior&quot;:&quot;show&quot;}" id="ck_form_options">
      <input type="hidden" name="id" value="32973" id="landing_page_id">
      <div class="ck_errorArea">
        <div id="ck_error_msg" style="display:none">
          <p>There was an error submitting your subscription. Please try again.</p>
        </div>
      </div>
      <div class="ck_control_group ck_email_field_group">
                                   <label class="ck_label" for="ck_emailField" style="display: none">Email Address</label>
                   <input type="email" name="email" class="ck_email_address" id="ck_emailField" placeholder="Enter your email" required autofocus>
      </div>

      <button class="subscribe_button ck_subscribe_button btn fields text-uppercase" id='ck_subscribe_button'>
        Start Class Now
      </button>
    </form>
  </div>

 </div>


</div>
</div>

CSS

 /* Layout */
  .ck_form.ck_naked {
  /* divider image */
    background: transparent;
    line-height: 1.5em;
    overflow: hidden;
    color: #666;
    font-size: 16px;
    border: none;
    -webkit-box-shadow: none;
    -moz-box-shadow: none;
    box-shadow: none;
    clear: both;
    margin: 0 0 0 0;
}

.ck_form.ck_naked p {
    padding: 0px;
}

.ck_form, .ck_form * {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.ck_form.ck_naked .ck_form_fields {
    width: 100%;
    float: left;
    padding: 5%;
        padding-bottom: 1.5%;
}
/* Form fields */

.ck_errorArea {
    display: none; /* temporary */
}

#ck_success_msg {
    padding: 10px 10px 0px;
    border: solid 1px #ddd;
    background: #eee;
}

.ck_form.ck_naked input[type="text"], .ck_form.ck_naked input[type="email"] {
    font-size: 18px;
    padding: 10px 8px;
    width: 34%;
    border: 1px solid #d6d6d6; /* stroke */
    -moz-border-radius: 0px;
    -webkit-border-radius: 0px;
    border-radius: 0px; /* border radius */
    background-color: #fff; /* layer fill content */
    margin-bottom: 5px;
    height: auto;
    float: left;
    margin: 0px;
    margin-right: 1%;
    height: 42px;
}

.ck_form input[type="text"]:focus, .ck_form input[type="email"]:focus {
    outline: none;
    border-color: #aaa;
}

.ck_form.ck_naked .ck_subscribe_button {
    width: 100%;
    color: #fff;
    margin: 0px;
    padding:  9px 0px;
    font-size: 18px;
    background: #0d6db8;
    -moz-border-radius: 0px;
    -webkit-border-radius: 0px;
    border-radius: 0px; /* border radius */
    cursor: pointer;
    border: none;
    text-shadow: none;
    width: 30%;
    float: left;
    height: 42px;
  }

.ck_form.ck_naked .ck_subscribe_button:hover { 
       background: #3d8ac6;

  }

.ck_converted_content {
  display: none;
    padding: 5%;
    background: #3d8ac6;
}

/* max width 500 */

    .ck_form.ck_naked.width500 .ck_subscribe_button {
        width: 100%;
        float: none;
        margin-top: 5px;
    }

    .ck_form.ck_naked.width500 input[type="text"], .ck_form.ck_naked.width500 input[type="email"] {
        width: 49%;
    }

    .ck_form.ck_naked.width500 input[type="email"] {
        margin-right: 0px;
        width: 50%;
    }

/* max width 400 */

    .ck_form.ck_naked.width400 .ck_subscribe_button, .ck_form.ck_naked.width400 input[type="text"], .ck_form.ck_naked.width400 input[type="email"] {
        width: 100%;
        float: none;
        margin-top: 5px;
    }

.ck_slide_up, .ck_modal, .ck_slide_up .ck_naked, .ck_modal .ck_naked  {
    min-width: 400px;
}

.page .ck_form.ck_naked {
    margin: 50px auto;
    max-width: 700px;
}

我最近从 MailChimp 切换到 ConverKit,它为我提供了大量代码供我粘贴。我可以轻松地以 position: relative 为中心,但在移动设备上查看时会出现倾斜。

最佳答案

尝试使用这段代码

我对您的 HTML 和 CSS 做了一些更改,希望这对您有用。

HTML

<div class="ck_form ck_naked ck_horizontal">

  <div class="ck_form_fields">

    <div id="ck_success_msg" style="display:none;">
      <p>Success! </p>
    </div>

    <!--  Form starts here  -->
    <form id="ck_subscribe_form" class="ck_subscribe_form" action="https://app.convertkit.com/landing_pages/32973/subscribe" data-remote="true">
      <input value="{&quot;form_style&quot;:&quot;naked&quot;,&quot;embed_style&quot;:&quot;inline&quot;,&quot;embed_trigger&quot;:&quot;scroll_percentage&quot;,&quot;scroll_percentage&quot;:&quot;70&quot;,&quot;delay_seconds&quot;:&quot;10&quot;,&quot;display_position&quot;:&quot;br&quot;,&quot;display_devices&quot;:&quot;all&quot;,&quot;days_no_show&quot;:&quot;15&quot;,&quot;converted_behavior&quot;:&quot;show&quot;}" id="ck_form_options" type="hidden">
      <input name="id" value="32973" id="landing_page_id" type="hidden">
      <div class="ck_errorArea">
        <div id="ck_error_msg" style="display:none">
          <p>There was an error submitting your subscription. Please try again.</p>
        </div>
      </div>
      <div class="ck_control_group ck_email_field_group">
                                   <label class="ck_label" for="ck_emailField" style="display: none">Email Address</label>
  <div class="col-md-8 col-md-offset-2" style="padding: 0px;">  
  <div class="subscription-section">

  <div style="padding-right: 0px;" class="col-md-6"><input name="email" class="ck_email_address" id="ck_emailField" placeholder="Enter your email" required="" autofocus="" type="email"></div>
      <div class="col-md-6"><button class="btn-block subscribe_button ck_subscribe_button btn fields text-uppercase" id="ck_subscribe_button">
        Start Class Now
  </button></div>
  </div></div></div>


    </form>
  </div>

 </div>

CSS

.greenpromobox {
    background-color: green;
    padding-top: 1px;
    margin-top: 25px;
    max-width: 740px;
    border-radius: 5px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 20px;
}
.subscription-section {
    overflow: hidden;
    margin-top: -30px;
}
.ck_form.ck_naked input[type="text"], .ck_form.ck_naked input[type="email"] {
    font-size: 18px;
    padding: 10px 8px;
    width: 100%;
    border: 1px solid #d6d6d6;
    -moz-border-radius: 0px;
    -webkit-border-radius: 0px;
    border-radius: 0px;
    background-color: #fff;
    margin-bottom: 5px;
    margin: 0px;
    height: 42px;
}
.ck_form.ck_naked .ck_subscribe_button {
    width: 100%;
    color: #fff;
    padding: 9px 0px;
    font-size: 18px;
    background: #0d6db8;
    -moz-border-radius: 0px;
    -webkit-border-radius: 0px;
    border-radius: 0px;
    cursor: pointer;
    border: none;
    text-shadow: none;
    width: 100%;
    height: 42px;
}

关于html - 使用 Bootstrap 将电子邮件输入和按钮居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36057870/

相关文章:

html - 弹性框根据屏幕分辨率对特定项目进行分组

javascript - 侧面导航的菜单图标

html - Scrollspy 事件部分未在导航栏上更新

javascript - 触发动态弹出窗口 HTML 表单的密码自动填充

ruby-on-rails - 带有验证的 form_for 未正确调用 "create"操作

javascript - 带有大边框的 jquery ui 可调整大小的 div

html - float 不起作用,第二个背景图像未注册为背景,居中?

html - 导航标题中带有图标的 Bootstrap 搜索字段未正确显示

html - 我的 Bootstrap 页面页脚下方的空白

javascript - 如果可滚动的 div 比窗口高,则将水平滚动条附加到窗口底部