jimfog Posted June 8, 2012 Share Posted June 8, 2012 I have a form and I want to put it in the center of the page. Usually when I want to center an element I use margin:0px auto; Now, with the form though, it does not work. I am going to depict the code and to inform also that the form is enclosed in another wrap div tag which serves as the main wrapper of the page. Here it is: #wrap{ width:100%; margin-left:auto; margin-right:auto; position: relative; font-size: 0.875em; overflow:hidden;}#form {margin:0px auto;} The HTML: <div id="wrap"> <form id="form" action="" method="post"> Username/e-mail:<input name="Username" type="text" size="35" /><br />Password:<input name="password" type="password" size="35" /><br /><input name="submit" type="button" value="submit" /> </form> </div> Link to comment Share on other sites More sharing options...
eTianbun Posted June 8, 2012 Share Posted June 8, 2012 Give the form element width! Link to comment Share on other sites More sharing options...
dsonesuk Posted June 8, 2012 Share Posted June 8, 2012 Block elements = define width: margin: 0 auto; inline elements = parent block element text-align: center; Link to comment Share on other sites More sharing options...
jimfog Posted June 8, 2012 Author Share Posted June 8, 2012 Yes now it works,thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.