You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress页脚订阅表单水平居中问题及解决方法

WordPress邮件订阅表单居中问题解决

我在为WordPress网站的页脚添加邮件订阅的shortcode,已经成功添加,但表单始终无法水平居中,一直靠左。我创建了包含两个ID的容器,其中文本已经实现居中,但表单的居中设置始终不生效。我试过多个解决方案都没用,肯定有简单的解决办法但我还没找到。以下是未生效的代码示例,以及最终解决问题的可行代码:

未生效代码

CSS代码

.tnp-subscription-minimal input[type=submit] {
  background-color: #224b37!important;
  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;
  margin-left: 2px;
  transition: all 0.23s ease-in-out 0s;
}

.tnp-subscription-minimal input[type=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;
}

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

HTML代码

<div class=“newsletter-wrapper” style="position: sticky; background-color:#c2cdc8; padding:60px 30px 60px 30px; width: 100%;">
  <div id="inscripcion" style="absolute: sticky; left: 50%; top: 50%; z-index: 9999">¿Quieres recibir todos mis posts? ⦙ <br> Do you want to receive my posts?</div>
  <div id="formulario-newsletter"  style="absolute: sticky; left: 50%; top: 50%;">
    <form calss="tnp-subscription-minimal">
      <input type="email" /> <button type="submit">OK!</button>
    </form>
  </div>
</div>

最终可行代码

CSS代码

.tnp-subscription-minimal input[type=submit] {
  background-color: #224b37!important;
  color: #ffffff;
  font: Poppins, sans-serif;
  font-weight: bold;
  margin: 0 auto;
    width: 16%;
  border: none;
  padding: 0 0px;
  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;
  margin-left: 2px;
  transition: all 0.23s ease-in-out 0s;
}

.tnp-subscription-minimal input[type=email] {
  font-family: Poppins, sans-serif;
  border: none;
  padding: 15px;
  width: 68%;
  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;
}

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

#formulario-newsletter {
  text-align: center;
}

HTML代码

<div class=“newsletter-wrapper” style="position: sticky; background-color:#c2cdc8; padding:45px 30px 60px 30px; width: 100%; display: flex; flex-direction: column; align-items: center;">
  <div id="inscripcion" style="z-index: 9999">¿Quieres recibir todos mis posts? ⦙ <br> Do you want to receive my posts?</div>
  <div id="formulario-newsletter">
<?php echo do_shortcode('[newsletter_form type="minimal"]'); ?> 
  </div>
</div>

文本已居中但表单未居中

内容的提问来源于stack exchange,提问作者imthemoisturizer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 23:47:23