I'm working on including a shortcode on the footer of my Wordpress website so that users may sign up to my newsletter.
I managed to include the shortcode itself on the footer, although I can't get it horizontally centered, it seems stuck on the left side. As you can see, I've created a class with two IDs inside of it, the first one with some written text and the second one with the form. The written text is centered, but I can't find the right way to center the form.
I tried different potential solutions, such as this, this and this, but none of them got it properly centered, it always stays off. I'm sure the solution must be simple, I just can't see it.
Non working code (solution is shown below):
.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;
}
<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>
I deliberately left the previous, non-working code in case it helps someone in a similar situation, this is how it ended up looking (and working properly):
.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;
}
<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>