...

View Full Version : Center a form but not the contents



benzen
09-11-2011, 12:13 AM
Hi,

I have the following form:



<form action="#" method="get">
<fieldset>
<legend>Date Range</legend>
<label for="startdate">
<span>Start Date:</span>
<input type="text" name="startdate" id="from"
maxlength="20" />
</label>

<label for="enddate">
<span>End Date:</span>
<input type="text" name="enddate" id="to"
maxlength="20" />
</label>
</fieldset>
<fieldset>
<center><input value="Create Report" type="submit"></center>
</fieldset>
</form>



And I want to center the form on the screen but I don't want to center all the contents of the form.

I have tried <Div align=center> but this centers everything.

I have css code:



fieldset {margin: 1em 5px; padding: 10px 10px; width: 170px;}
legend {padding: 0.2em 0.5em; color:green; font-size:120%; text-align:left;}


for the fieldset and I want the legend to stay to the left side, but everytime I try css in DIVs I always end up centering everything.

Any help would be greatfully received.

Ben

Mr.
09-11-2011, 12:55 AM
just use a margin on the Div like this...

div { margin: 0 auto; }

benzen
09-11-2011, 10:25 PM
That didn't seem to work??

Here is the script on the page:

http://www.jewelleryandgifts4u.co.uk/test/test.php

Can you see what I may be doing wrong?

Thanks in advance

conware
09-11-2011, 11:56 PM
Benzen I just checked your website and your form is centered.
If you're talking about the fieldset which is aligned to the left you should change:


fieldset {margin: 1em 5px;}
To:

fieldset {margin: 1em auto;}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum