Click to See Complete Forum and Search --> : Understanding CSS: Layouting Simple Form


jens1701
12-19-2008, 08:01 AM
Hi,

i played with this form, but dont get it to work the way i like it.
The picture shows whats it should look like... including flexiblity in width.

So my main problem is, that i can't set the width of the input elements to 100% of the parent element without linebreak and horizontal overflow.

Thoughts:
- Problem with Block Formating Context
- Is it possible for a form element input to auto take all the width they can get?

Please give me a hand.

Greets

Jens

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>test</title>

<style type="text/css">
<!--
fieldset { }
#mail_form_fields { overflow: hidden; }

#mail_form_fields div.line { margin: 5px 0;}
#mail_form_fields div.line div { float:left;}
#mail_form_fields input { border: 0.3em solid green; width:100%; }
#mail_form_fields label { float: left; width:100px; text-align: center; }

//-->
</style>

</head>
<body>
<form action="index.php?id=55" id="mailform" enctype="multipart/form-data" method="post">
<fieldset>
<div class="invisible">
<input type="hidden" name="html_enabled" id="mailformhtml_enabled" value="" />
<input type="hidden" name="subject" id="mailformsubject" value="Lorem Ipsum Dolor Siamet" />
<input type="hidden" name="locationData" value="55:tt_content:113" />
</div>
<div id="mail_form_fields">
<div class="line">
<label for="name">Name</label>
<div><input id="name" type="text" name="Name" size=40 value="Lorem Ipsum Dolor Siamet" /></div>
</div>
<div class="line">
<label for="mail">E-Mail</label>
<input id="mail" type="text" name="mail" size=40 value="Lorem Ipsum Dolor Siamet" />
</div>
<div class="line">
<label for="topic">Thema</label>
<input id="topic" type="text" name="Thema" size=40 value="Lorem Ipsum Dolor Siamet" />
</div>
<textarea id="nachricht" name="message" cols="50" rows="10">Lorem Ipsum Dolor Siamet.</textarea>
<div id="submit"><input type="submit" value="Abschicken" /></div>
</div>
</fieldset>
</form>
</body>

zvezdochet
12-20-2008, 05:35 AM
Hey, I did something similar to what your picture shows.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<style type="text/css">
p {font-size: 12px;}
p.i {font-size: 12px; font-weight: bold;}
#f {float: left; width: 310px; height: 600; margin: 2px 0px 0px 2px; padding: 5px 0px 0px 5px; background: #fff;
border: 0px solid; border-color: #999; }
#f_i {float: left; width: 285px; height: 24px; margin: 10px 0px 0px 5px; padding: 5px 0px 0px 15px; background: #dfebab;
font-size: 12px; font-family: arial,serif; font-weight: bold;}
#f_t {float: left; width: 296px; height: 264px; margin: 10px 0px 0px 5px; padding: 5px 0px 0px 5px; background: #dfebab;}
#f_b {float: left; margin: 5px 0px 5px 100px;}
input.ii {border: none; padding: 1 0 0 1;}
textarea.tt {border: none;}
.button {border: #c8c8c8 1px solid; background-color: #a8ca54; height: 25px;}
</style>
</head>
<body>
<div id="f">
<form action="index.php?id=55" enctype="multipart/form-data" method="post">
<div id="f_i"><label for="mail">Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input id="name" type="text" name="name" size="34" maxlength="30" value="Lorem Ipsum Dolor Siamet" class="ii" />
</div>
<div id="f_i"><label for="mail">E-Mail&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input id="mail" type="text" name="mail" size="34" maxlength="30" value="Lorem Ipsum Dolor Siamet" class="ii" />
</div>
<div id="f_i"><label for="topic">Betreff&nbsp;&nbsp;&nbsp;</label>
<input id="topic" type="text" name="betreff" size="34" maxlength="30" value="Lorem Ipsum Dolor Siamet" class="ii" />
</div>
<div id="f_t"><textarea name="message" cols="34" rows="15" class="tt">Geben Sie bitte hier Ihre Nachricht ein. </textarea>
</div>
<div id="f_b"><button name="Abschicken" type="submit" class="button">Absenden</button></div>
</form>
</div>
</body>
</html>