Your Ad Here

Posted By

KF on 09/22/09


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

KF
satsuma


Form


 / Published in: CSS
 

URL: http://www.assemblesoft.com/examples/form/simpleform.html

  1. <form action="?">
  2. form * {margin:0;padding:0;} /* Standard margin and padding reset, normally done on the body */
  3.  
  4. legend {
  5. color:#000; /* IE styles legends with blue text by default */
  6. *margin-left:-7px; /* A hack that only ie reads to position the legend in the same place cross browser */
  7. }
  8. fieldset {
  9. border:1px solid #dedede; /* Default fieldset borders vary cross browser, so make them the same */
  10. }
  11. fieldset div {
  12. overflow:hidden; /* Contain the floating elements */
  13. display:inline-block; /* Give layout in ie to contain float */
  14. }
  15. fieldset div {display:block;} /* Reset element back to block leaving layout in ie */
  16. label {
  17. float:left; /* Take out of flow so the input starts at the same height */
  18. width:5em; /* Set a width so the inputs line up */
  19. }
  20.  
  21. .radio {
  22. position:relative; /* Position so children are relative to this container */
  23. border:0; /* Remove the border */
  24. }
  25. .radio span {
  26. position:absolute; /* Take the content of the legend out of flow */
  27. top:0;left:0; /* and position it to the top left of the fieldset */
  28. width:5em; /* Same width as labels */
  29. }
  30. .radio ul {
  31. margin-left:5em; /* Since the legend is out of flow. set margin, so inputs are inline */
  32. list-style:none; /* Dont want bullets */
  33. }
  34. .radio li {
  35. position:relative; /* Fix a bug in IE zoom functionality */
  36. display:inline; /* Display the inputs in a line */
  37. white-space:nowrap; /* We dont want a label to wrap between the input and label */
  38. }
  39. .radio label, .radio input {
  40. width:auto; /* Reset the width on the label from the 5em, set earlier */
  41. float:none; /* Reset the float from left on the label, set earlier */
  42. vertical-align:middle; /* Align the radio buttons with the inputs */
  43. }
  44.  
  45.  
  46.  
  47. <fieldset>
  48. <legend>Contact</legend>
  49. <div><label for="name">Name</label> <input id="name" name="name"></div>
  50. <fieldset class="radio">
  51. <legend><span>Gender</span></legend>
  52. <ul>
  53. <li><input type="radio" id="male" name="male"> <label for="male">Male</label></li>
  54. <li><input type="radio" id="female" name="female"> <label for="female">Female</label></li>
  55. </ul>
  56. </fieldset>
  57. </fieldset>
  58. </form>

Report this snippet  

You need to login to post a comment.