CSS Grid System for Forms (Multi-Column)

前端 未结 8 1558
时光说笑
时光说笑 2021-01-30 02:20

For future reference here is the final result with pixel perfect precision:

The CSS code:

._25 {
    width: 21%;
    display:          


        
相关标签:
8条回答
  • 2021-01-30 03:12

    One answer is Blueprint. I have read where you don't think it's the answer, but it's still the way I would do it. All the ease of tables with all the power of CSS.

    With blueprint the math is pretty easy. Let's say your form spans 10 columns.

    <div id="contact-form" class="span-10">
      <h3>Contact Form</h3>
      <form action="contact">
      <div id="form-sec-1" class="span-5">
         <label>Name</label> <br/>
         <input type="text" name="name" /> <br/>
         <label>ZIP code</label> <br/>
         <input type="text" name="zipcode" />
      </div>
      <div id="form-sec-2" class="span-5 last">
         <label>Email</label> <br/>
         <input type="text" name="email" /> <br/>
         <label>Country</label> <br/>
         <input type="text" name="country" />
      </div>
      <div id="form-sec-3" class="span-10 last">
         <label>Message</label> <br/>
         <textarea name="message" />
      </div>
      <div id="form-sec-4" class="span-8">
        <input type="checkbox" name="copy"/>
        <label>Send me a copy</label>
      </div>
      <div id="form-sec-5" class="span-2">
         <input type="submit"/>
      </div>
      </form>
    </div>
    
    0 讨论(0)
  • 2021-01-30 03:14

    I think this is what you are looking for:

    http://www.alistapart.com/articles/prettyaccessibleforms/

    It should help simplify your structure a little bit. It doesn't explicitly describe how to make multiple column forms, but the technique could probably expand to that with some creativity on your part.

    0 讨论(0)
提交回复
热议问题