CSS Forms

  • SpooF
  • Ice Cream
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 2826
  • Loc: Richland, WA
  • Status: Offline

Post October 12th, 2006, 10:19 pm

I want to make colums with CSS so I can have all the inputs aligned. Anyone know how to do this?

Ive looked but the only thing I can find is this

http://jeffhowden.com/code/css/forms/
College Taught Me - And we're not talking about the classes!
@travisperson
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 12th, 2006, 10:19 pm

  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Joined: May 29, 2005
  • Posts: 1397
  • Loc: 55° N, 3° W
  • Status: Offline

Post October 13th, 2006, 3:30 am

When you use:

<fieldset>
<legend></legend>
<label></label>

</fieldset>

the whole thing kinda lines itself up automatically.
  • fmx
  • Newbie
  • Newbie
  • User avatar
  • Joined: May 02, 2005
  • Posts: 6
  • Loc: subway num.9
  • Status: Offline

Post October 13th, 2006, 4:14 am

this might help- http://alistapart.com/articles/practicalcss/ ... scroll down a lil to find the form part.
  • Nightslyr
  • Proficient
  • Proficient
  • No Avatar
  • Joined: Sep 21, 2005
  • Posts: 254
  • Status: Offline

Post October 13th, 2006, 4:37 am

SpooF wrote:
I want to make colums with CSS so I can have all the inputs aligned. Anyone know how to do this?

Ive looked but the only thing I can find is this

http://jeffhowden.com/code/css/forms/


I do the following (and yeah yeah...I know I don't need both a name and ID for my inputs):

Code: [ Download ] [ Select ]
// My CSS:

form p label {
  font: bold 1em Arial, Helvetica, sans-serif;
  float: left;
  width: 30%;
}

form p {
  clear: left;
  margin: 0;
  padding: 5px 0 0 0;
}

input.txt {
  width: 200px;
}

fieldset.narrow {
  width: 450px;
}

<!-- XHTML -->

<form id="inputform" method="post" action="">
  <fieldset class="narrow"><legend>Please input your information</legend>
   <p><label for="name">Name:</label><input name="username" id="username" type="text" class="txt" /></p>
   <p><label for="password">Password:</label><input name="password" id="password" type="password" class="txt" /></p>
   <p><label for="email">E-mail Address:</label><input name="email" id="email" type="text" class="txt" /></p>
   <p><input type="submit" name="submit" id="submit" value="Submit" /></p>
  </fieldset>
</form>
  1. // My CSS:
  2. form p label {
  3.   font: bold 1em Arial, Helvetica, sans-serif;
  4.   float: left;
  5.   width: 30%;
  6. }
  7. form p {
  8.   clear: left;
  9.   margin: 0;
  10.   padding: 5px 0 0 0;
  11. }
  12. input.txt {
  13.   width: 200px;
  14. }
  15. fieldset.narrow {
  16.   width: 450px;
  17. }
  18. <!-- XHTML -->
  19. <form id="inputform" method="post" action="">
  20.   <fieldset class="narrow"><legend>Please input your information</legend>
  21.    <p><label for="name">Name:</label><input name="username" id="username" type="text" class="txt" /></p>
  22.    <p><label for="password">Password:</label><input name="password" id="password" type="password" class="txt" /></p>
  23.    <p><label for="email">E-mail Address:</label><input name="email" id="email" type="text" class="txt" /></p>
  24.    <p><input type="submit" name="submit" id="submit" value="Submit" /></p>
  25.   </fieldset>
  26. </form>


I got this kind of setup from one of the Sitepoint books.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 97 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.