/    Sign up×
Community /Pin to ProfileBookmark

CSS and Forms

Hi,

I want to know how to use CSS to create a form without tables by using <div> tags. I have tried it but everytime I change the size of my browzer window the form changes aswell.
[U]My question[/U]: What can I do to make the form retain the original shape(form) eventhough I change the size of my browzer window?

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarJun 06.2005 — You will proberly need to user absalute values if you don't want it to change size, although I would discurage this since percentages are used to ensure every user, regardless of moniter size, sees the page the same.
Copy linkTweet thisAlerts:
@NogDogJun 06.2005 — You can put the form within a fixed-width div. And if you use em units for all fixed dimensions (including the div's width), the form will maintain its proportions if the user changes the font size via the browser's view options:
[code=html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'>
<title>Sample Form</title>
<style type="text/css">
<!--
body {
font-family: medium arial, helvetica, sans-serif;
margin: 0;
padding: 10px;
}
#form {
width: 25em;
margin: 0 auto;
padding: 0.5em;
background-color: silver;
border: outset 2px silver;
}
label {
display: block;
float: left;
width: 5.5em;
}
#form p {
margin: 0.5em 0;
}
fieldset {
margin: 0;
padding: 0.5em;
}
-->
</style>
</head>
<body>
<div id=form>
<form action="#" method=post>
<fieldset>
<legend>Sample Form</legend>
<p>
<label for=field1>Field 1:</label>
<input name=field1 type=text size=20 maxlength=20>
</p>
<p>
<label for=field1>Field 2:</label>
<input name=field2 type=text size=20 maxlength=20>
</p>
<p><label for=text>Enter text:</label></p>
<p><textarea name=text rows=4 cols=40></textarea></p>
</fieldset>
</form>
</div>
</body>
</html>
[/code]
×

Success!

Help @Felixcat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...