vertical alignment in a input box
I have not managed to spot a way to center the text in a input box.. I have changed the height of the box to 40px using the code below..
<input id="uname" style="height:40px; padding-top:10px;" type ="text" Name="userName" />
as you can see the height is 40px and i tried to use vertical-align:middle didnt work
I have tried <input id="uname" style="height:40px; text-align:center;" type ="text" Name="userName" /> this places the cursor in the center center of the txt box.. not vertical left center which is what i want
I noted the box is 40px high so tried padding top:20px this is 40/2 no joy..
so i tried padding-top:10px which moves the cursor 10 px from the top and this is the center I guess the top of the cursor is now 10px from the top.. and that does work..
But I then tried out of curosity padding-bottom:10px; this doesnt work..?
I really didnt want to hard code any numbers just wanted to be able to use a phrase like in a table you can use valign what about for input tags..?
Here is all my code..
To sumarize I would request why does padding-top:10px work where as padding-bottom:10px which in my mind is the same but from the bottom doesnt work..
and why cant there be a phrase like vertical-align or something to do this what it my input box is 45px high 45/2 = 22.5 this then makes the padding bit not accurate..
I just want the cursor to sit on the left vertical center of input box or any input box.?
<html><head><title>longin page</title> </head> <body> <form ACTION="login.php" Method="POST"> <table border ="1" cellspacing ="10" cellpadding="0"> <tr> <td style ="font-size:16pt; font-family:Arial;"> <label for="uname"> Username: </label> </td> <td> <input id="uname" style="height:40px; text-align:center;" type ="text" Name="userName" /> </td> </tr> <tr> <td style ="font-size:16pt; font-family:Arial;"> <label for="pass">Password: </label> </td> <td> <input id="pass" style="height:40px; padding-top:10px;" type ="password" Name="password"/> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="Login"/ style="font-size:16pt; font-family:Arial;color:white;"> </td> </tr> </table> </form><br/> </body> </html> Started By Laurencek on Feb 7, 2010 at 3:47:47 PM |