Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center form submit buttons HTML / CSS

I'm having troubles centering my HTML form submit buttons in CSS.

Right now I'm using:

    <input value="Search" title="Search" type="submit" id="btn_s">     <input value="I'm Feeling Lucky" title="I'm Feeling Lucky" name="lucky" type="submit" id="btn_i"> 

with this CSS content

#btn_s{     width: 100px;     margin-left: auto;     margin-right: auto; }  #btn_i {     width: 125px;     margin-left: auto;     margin-right: auto; } 

And it's not doing anything. I know I'm probably doing something stupid wrong. How can I fix this?

like image 410
Belgin Fish Avatar asked Nov 19 '10 01:11

Belgin Fish


People also ask

How do I center a button in form element?

You can center a block level element by setting margin-left and margin-right to auto . We can use the shorthand margin: 0 auto to do this. (This also sets margin-top and margin-bottom to zero.)

How do I center a form in HTML CSS?

Use the CSS text-align Property to Center a Form in HTML We can set the value to center to center the form. For example, apply the text-align property to the form tag in the style attribute, and set the property to center . Next, create input tags with the type text and then submit .

How do you make a submit Center in HTML?

use text-align:center on the parent container, or create a container for this. if the container has to have a fixed size, use auto left and right margins to center it in the parent container.

How do I move the submit button in HTML?

Steps to move the Submit buttonFigure out the coordinates where you'd like the new Submit button to go. The Submit button on Wufoo forms all have the same ID – 'saveForm. ' With the custom CSS file, change the position of the button, using the new coordinates. Attach the custom CSS file to your theme.


1 Answers

http://jsfiddle.net/SebastianPataneMasuelli/rJxQC/

i just wrapped a div around them and made it align center. then you don't need any css on the buttons to center them.

<div class="buttonHolder">   <input value="Search" title="Search" type="submit" id="btn_s">    <input value="I'm Feeling Lucky" title="I'm Feeling Lucky" name="lucky" type="submit" id="btn_i"> </div>  .buttonHolder{ text-align: center; } 
like image 160
Sebastian Patane Masuelli Avatar answered Sep 30 '22 19:09

Sebastian Patane Masuelli