Align form field and submit button on same line

Josh Martin

I feel that I'm really missing something simple, but I have tried many things and can't seem to align the submit button on the right side of the input box on the same line. It is on the next line below the text box.

This comes from a wordpress plugin where I can add some additional CSS, so some of the CSS isn't being pulled in my jfiddle example, but I think you have what you need.

HTML

    <div class="tnp tnp-subscription">
<form method="post" action="http://www.buffettworld.com/bw18/?na=s" onsubmit="return newsletter_check(this)">

<div class="tnp-field tnp-field-email"><input class="tnp-email" type="email" name="ne" placeholder="Enter your e-mail address" required></div>
<div class="tnp-field tnp-field-button"><input class="tnp-submit" type="submit" value="Subscribe">
</div>
</form>
</div>

CSS

.tnp-subscription {
    font-size: 13px;
    display: block;
    margin: 15px auto;
    max-width: 500px;
    width: 100%;
}

.tnp-subscription input.tnp-submit {
    background-color: #6acbdc;;
    color: #fff;
    width: auto;
    height: auto;
}

https://jsfiddle.net/martonian/u41y9bng/2/

Gerard

My prefered solution would be using a flexbox for the form.

form {
  display: flex;
  align-items: center; /* Vertical alignment */
}

.tnp-subscription {
  font-size: 13px;
  display: block;
  margin: 15px auto;
  max-width: 500px;
  width: 100%;
}

.tnp-subscription input.tnp-submit {
  background-color: #6acbdc;
  ;
  color: #fff;
  width: auto;
  height: auto;
}
<div class="tnp tnp-subscription">
  <form method="post" action="http://www.buffettworld.com/bw18/?na=s" onsubmit="return newsletter_check(this)">
    <div class="tnp-field tnp-field-email"><input class="tnp-email" type="email" name="ne" placeholder="Enter your e-mail address" required></div>
    <div class="tnp-field tnp-field-button"><input class="tnp-submit" type="submit" value="Subscribe">
    </div>
  </form>
</div>

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

Align Divs on Same Line

HTML "required" attribute for multiple button with multiple text field on same form

Javascript cannot submit form with empty field validation

Javascript form submit button not working innerHTML

issue With Contact Form 7 submit button

Update form status by changing submit button text

HTML form submit button not working in mobile phones

Disable submit button if form not filled out

How to align divs horizontally on the same line bootstrap

Align text and image on the same line React Native

Ajax form submit twice or once but missing last value no submit button

Highlight submit button when focus on input field in html

After form submit show / hide div +input field based on checkbox?

Trigger Form submit on Button click in Vue Unit Test

Disable angularjs form submit button if image size is big

POST value of form via click on submit button (express)

can't submit form with button to create new user

How to display form data in popup after clicking on submit button

Is there any way to add just an icon to a MailChimp embed form 'submit' button?

Getting inconsistent styling (colors) on submit button in WordPress Elementor form

Disable Submit button if the form fields' values have not changed in Vue/Nuxt

How should one align an image in the same line with the content of a <nav> tag?

How do I align two elements on the same line?

How to align two paragraphs to the left and right on the same line?

Align two divs on the same line without modifying the HTML

How to align two span elements separately but in same line

Submit button not showing up in the same area on different screens

Display message after php form submit INSIDE same page

Collect values of multiple checkboxes in PHP (2 submit in same form ?)

TOP Lista

CalienteEtiquetas

Archivo