I'm trying to build a form using floating divs as opposed to my normal approach of using a table. I've reached the submit button and am trying to center it. Normally a DIV, being a block element, will automatically use up a whole line and have a line break after it won't it? But mine doesn't and I can't figure out why. I tried explicitly setting it's width to 100% and it still won't use the full width. To confuse me more, the div is styled with clear:both; which I thought should prevent any content from floating next to it. I also tried putting its following text in its own div but nothing changed. Why does the text float next to the submit div?
<style type="text/css">
#rlpContactForm
{
width:275px;
}
#rlpContactForm label
{
display:block;
float:left;
width:112px;
text-align:right;
font-weight:bold;
}
#rlpContactForm input
{
float:left;
margin:0 0 5px 5px;
}
#rlpContactForm input[type="text"]
{
border: 1px solid #999999;
}
#rlpContactForm input[type="text"]
{
width: 146px; /*175 available - total width of label (including margins/borders/10pxwiggle room)*/
padding: 1px 0px 1px 0px; /* Otherwise IE adds 1px right and left padding automatically */
}
#rlpContactForm input[type="text"].age
{
width: 44px; /* Sized for 3 boxes to fit 1 line */
margin: 0 0 5px 5px;
text-align:center;
}
#rlpContactForm .submit
{
float:none;
clear:both;
width:100%;
text-align:center;
}
</style>
...
<div id="rlpContactForm">
<label>First Name:</label>
<asp:TextBox ID="txtFName" runat="server" />
<label>Last Name:</label>
<asp:TextBox ID="txtLName" runat="server" />
<label>E-mail:</label>
<asp:TextBox ID="txtEmail" runat="server" />
<label>Phone:</label>
<asp:TextBox ID="txtPhone" runat="server" />
<label>Children's Ages:</label>
<asp:TextBox ID="txtAge1" runat="server" CssClass="age"/>
<asp:TextBox ID="txtAge2" runat="server" CssClass="age"/>
<asp:TextBox ID="txtAge3" runat="server" CssClass="age"/>
<div class="submit"><asp:Button ID="btnSubmit" runat="server" Text="Submit"/></div>
Thank you for your interest. A team member will contact you shortly.
</div>
IE and Firefox show like
|Submit|Thank you for your interest. A
team member will contact you
shortly.