Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 1.52 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. HTML form alignment - input with label
  2. <form method="post" action="?test" id="form">
  3.     <label for="user">USERNAME</label>
  4.     <input type="text" name="user" id="user" maxlength="100" title="Please enter your username." data-h5-errorid="empty-user" tabindex="1" required />
  5.     <div id="empty-user" class="fail">This stuff will get replaced by the title contents.</div>
  6.     <label for="password" class="clear">PASSWORD</label>
  7.     <input type="password" name="password" id="password" maxlength="100" title="Please enter your password." data-h5-errorid="empty-password" tabindex="2" required />
  8.     <div id="empty-password" class="fail">This stuff will get replaced by the title contents.</div>
  9. </form>
  10.        
  11. label {
  12.     background: yellow;
  13.     font-size: 12px;
  14.     font-weight: bold;
  15.     width: 100px;
  16.     float: left;
  17.     margin-right: 50px;
  18.     text-align: right;
  19.     cursor: pointer;
  20. }
  21.  
  22. input {
  23.     height: 30px;
  24.     background-color: #fafafa;
  25.     border: 1px solid #abaaaa;
  26.     width: 300px;
  27.     margin: 5px 0 5px 0;
  28.     float: right;
  29. }
  30.        
  31. vertical-align: middle;
  32.        
  33. <div class="field">
  34.     <label for="user">USERNAME</label>
  35.     <div class="field-subject">
  36.         <input type="text" name="user" id="user" maxlength="100" title="Please enter your username." data-h5-errorid="empty-user" tabindex="1" required />
  37.     </div>
  38. </div>
  39.  
  40. .field {
  41.     overflow: auto; /* this "clears" the floated elements */
  42.     margin-bottom: 10px;
  43. }
  44.  
  45. .field label {
  46.     float: left;
  47.     width: 200px;
  48. }
  49.  
  50. .field .field-subject {
  51.     float: left;
  52.     width: 500px;
  53. }