Saturday 15 January 2011

align text fields to right html form css -


I am trying to align the text field of a form to the right of the divide in which they are included. I have this for CSS:

application.css

  #loginform {width: 400px; Height: 300px; Background: RGBA (237, 19, 192, 1); Margin-left: 0 pixels; Padding: 10px; } #usertext, #passtext {text-align: left; } # Login_writer, # login {text-align: right; } #submitbutton {text-align: center; }   

This is my html:

indexform.php

   & Lt; Div id = "usertext" & gt; & Lt; P & gt; Username: & lt; / P & gt; & Lt; / Div & gt; & Lt; Div id = "passtext" & gt; & Lt; P & gt; Password: & lt; / P & gt; & Lt; / Div & gt; & Lt; Div id = "loginuser" & gt; & Lt; Input name = "myusername" type = "text" id = "myusername" & gt; & Lt; / Div & gt; & Lt; Div id = "loginpass" & gt; & Lt; Input name = "mypassword" type = "password" id = "mypassword" & gt; & Lt; / Div & gt; & Lt; Div id = "submitbutton" & gt; & Lt; Input type = "submit" name = "submit" value = "login" & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Div & gt;   

What happens now:

  Username: Password: | --Usage text file - | | - Password Text File - | | -Login Button- |   

The text field must be aligned to the right of the label "Username:" and "Password:".

I did this

  & lt ; Div id = "loginuser" & gt; & Lt; Input name = "myusername" type = "text" id = "myusername" & gt; & Lt; / Div & gt; & Lt; Div id = "usertext" & gt; & Lt; P & gt; Username: & lt; / P & gt; & Lt; / Div & gt; & Lt; Div id = "loginpass" & gt; & Lt; Input name = "mypassword" type = "password" id = "mypassword" & gt; & Lt; / Div & gt; & Lt; Div id = "passtext" & gt; & Lt; P & gt; Password: & lt; / P & gt; & Lt; / Div & gt;   

and

  #loginuser, #loginpass {float: right; }    

No comments:

Post a Comment