Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Help with 6 column forms layout

  1. #1
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with 6 column forms layout

    Hello!

    I need som help with a 6 column layout for my application.
    The form should have a fixed layout, 800 pixels.

    Example:


    Column 1: Label (Fixed size)
    Column 2: Mandatory icon (visible or not dependning on if the field is mandatory)
    Column 3: Field (could be different fields, radio, dropdown, textarea....)
    Column 4: Label (Fixed size)
    Column 5: Mandatory icon (visible or not dependning on if the field is mandatory)
    Column 6: Field (could be different fields, radio, dropdown, textarea....)

    I also want borders as shown in the example image, but only 1 pixel, not two (I had som problems with that).
    All information in "cells" should be centered vertically. Mandatory icon should be centered both vertically och horizontally.
    Only css, no tables :roll:

    We are not using CSS3 yet...

    Is this enough information to get some help?

    Any help would be appreciated...

    //Randomizer

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    What code do you have so far? Please post a link to your page or paste the full code that's you've already prepared.

    Also, you haven't actually stated your problem.
    Please explain which aspect you're getting stuck on or are you asking for somebody to code the table layout for you?

    You might find this free/open source WYSIWYG website builder useful - Kompozer; http://www.kompozer.net-download.php
    You can draw tables with it quite easily and set cell properties (centered, align left, etc). You can also quickly flick back and forth into HTML code view so you can copy the generated table code to paste into your own web page. Or open your whole web page in Kompozer in the first instance and edit it there.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi!

    My goal is to find the most flexible css solution for building this
    type of form, no tables. I've searched and found many different
    solutions...that's why I'm getting a bit confused.

    The HTML:
    <div id="row1">
    <div style="label">Label 1:</div>
    <div style="mandatory"><div>
    <div style="field"><input type="text" name="textfield1"/></div>
    <div style="label">Label 2:</div>
    <div style="mandatory"><div>
    <div style="field"><input type="text" name="textfield2"/></div>
    </div>

    Regarding the CSS, I'm not an expert, that's why I'm asking for your help.
    How to use Float in CSS for example...

    I have Dreamweaver CS4, so I'm not in need of a HTML editor, thanks anyway for the link.

    Thanks again.

    //Randomzizer

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    OK - I'm not a CSS expert either but this looks like a pretty good starting point;
    (tested on IE6/7/8, Chrome, Firefox, Opera and Safari - Windows platform)

    Code:
    <html>
    <head>
    <title>Tableless Form Test</title>
    
    
    <style type="text/css">
    body { color:#666; font:10pt verdana; } /*just to make the page look nicer */
    
    .row { width:800px; clear:left; }
    .row div { border-top:1px solid #999; border-right:1px solid #999; height:30px; padding:0 3px; float:left; }
    .label { width:150px; }
    .label p, .icon p { margin-top:6px; }
    .icon { color:red; font-weight:bold; text-align:center; width:25px; }
    .formfield { width:200px; }
    .formfield input { margin-top:4px; }
    .left { border-left:1px solid #999; }
    .bottom div { border-bottom:1px solid #999; }
    </style>
    
    <!--[if IE]>
    <style type="text/css">
    .formfield input { margin-top:2px; }
    </style>
    <![endif]-->
    
    </head>
    
    
    <body>
    
    
    <div class="row">
    <div class="label left"><p>Label 1:</p></div>
    <div class="icon"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield1"/></div>
    <div class="label"><p>Label 2:</p></div>
    <div class="icon"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield2"/></div>
    </div>
    
    <div class="row bottom">
    <div class="label left"><p>Label 3:</p></div>
    <div class="icon"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield3"/></div>
    <div class="label"><p>Label 4:</p></div>
    <div class="icon"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield4"/></div>
    </div>
    
    
    </body>
    </html>
    Note the extra class of "bottom" required on the very last row and also "left" required in the first occurance of the label on each row.

    Also, its not exactly 800px wide - I've just gone with the closest 5px increment on .label, .icon and .formfield widths so when combined they total something close to 800px.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    This might also get you started with understanding floats: http://webdesign.about.com/od/advanc...a/aa010107.htm
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #6
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your reply.

    I will test your code.

    //Randomizer

  7. #7
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Why using the <p> tags arround the label and mandatory?

    //Randomizer

  8. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    So you can target the text with ".icon p" and ".label p" in the CSS and give them the margin-top value that creates the centered vertical-alignment effect (its this that pushes the text away from the "cell" top border).

    If you didn't use the <p>, you'd have to use internal padding on the containing div "cell" instead, and that would also increase the height of the "cell" so the text wouldn't appear to be centered vertically. The div "cells" sat in a row would then all be different heights and not look like a neat grid anymore.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  9. #9
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, this is what I've got so far:

    Code:
    <html>
    <head>
    <title>QS Forms</title>
    
    
    <style type="text/css">
    body { color:#666; font-family: arial; } /*just to make the page look nicer */
    
    .formheader {
    	width:300px;
    	border-top:1px solid #999;
    	border-left:1px solid #999;
    	border-right:1px solid #999;
    	background-image: url(formHeaderBg.jpg);
    	background-repeat: repeat-x;	
    	
    }
    
    .formheader p {
    	margin-top:3px;
    	font-size: 13px;
    	font-weight: bold;
    	padding:0 3px;
    	height:18px;
    }
    
    .row {
    	width:800px;
    	clear:left;
    	border-top:1px solid #999;
    	border-right:1px solid #999;
    	background-color: #EFEFEF;
    }
    
    .row div {
    	height:30px;
    	padding:0 3px;
    	float:left;
    	
    }
    
    .label { 
    	width:150px; 
    	border-left:1px solid #999;
    }
    
    .label p {
    	margin-top:7px;
    	font-size: 11px;
    	font-weight: bold;
    }
    
    .mandatory p {
    	margin-top:4px;
    	font-size: 18px;
    	font-weight: bold;
    	color:#FCB711;
    	text-align:center;
    }
    
    .mandatory {
    	width:25px;
    	}
    	
    .formfield { 
    	width:200px; 
    	}
    	
    .formfield input,textarea { 
    	margin-top:3px; 
    	font-size: 11px;
    	width:218px;
    	}
    	
    .left {
    	border-left:1px solid #999;
    	}
    	
    .bottom div { 
    border-bottom:1px solid #999; 
    }
    </style>
    
    <!--[if IE]>
    <style type="text/css">
    .formfield input { margin-top:4px; }
    </style>
    <![endif]-->
    
    </head>
    
    
    <body>
    
    <div class="formheader"><p>Global settings</p></div>
    <div class="row">
    <div class="label left"><p>Label 1:</p></div>
    <div class="mandatory"><p> > </p></div>
    <div class="formfield"><textarea name="" cols="3" rows="6"></textarea></div>
    <div class="label"><p>Label 2:</p></div>
    <div class="mandatory"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield2"/></div>
    </div>
    
    
    
    <div class="row bottom">
    <div class="label left"><p>Label 3:</p></div>
    <div class="mandatory"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield3"/></div>
    <div class="label"><p>Label 4:</p></div>
    <div class="mandatory"> <p>></p> </div>
    <div class="formfield"><input type="text" name="textfield4"/></div>
    </div>
    
    
    
    </body>
    </html>
    When I added a textarea I've received som strange results with the borders.
    The css class ".row div" has a fixed height and it doesn't "follow" the height
    of the textarea. The label and the yellow mandatory arrow should also
    be vertically centered in this case.



    Any clue?

    Thanks again for your help.

    //Randomizer

  10. #10
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    There isn't a valign equivelant on div as there are on table cells that's why I surrounded the text in paragraph tags and gave the margin-top:6px value in the CSS but that only works visually with the current row height of 30px.

    If you occasionally need different height "cells" you should add an additional class to the div "cells" in that row and assign a larger margin-top value that will push the text down further.

    This is why tables are much easier to manipulate in such cases as these and why we don't see common div use like this elsewhere on the web. As seen from my test, divs CAN be used to mock up something similar but they take much more work (I know as I was sat for over an hour faffing with the CSS for you) so that's why folk tend to opt for a table when laying out forms.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •