2010-06-15 34 views
0

我的註冊頁面目前看起來如下: alt text http://img691.imageshack.us/img691/4033/currento.pngasp.net標籤和asp.net文本框不正確排隊?

目前的造型我對上面的圖像是:

<style type="text/css"> 
#contactinfo label 
{ 
    float: left; 
    width: 10em; 
    margin-right: 0.5em; 
    text-align: right; 
    font-size: 14px; 
} 

#contactinfo p 
{ 
    padding: 5px; 
} 
#contactinfo input[type="text"], input[type="password"] 
{ 
    height: 1.5em; 
} 
#contactinfo select 
{ 
    padding: 0.25em; 
} 
#contactinfo input[type="text"]:focus, input[type="password"]:focus 
{ 
    background-color: #FFFFE0; 
} 

#contactinfo .update 
{ 
    margin-left: 12.5em; 
} 
#contactinfo .error 
{ 
    background-color: transparent; 
} 
#contactinfo .longtextbox 
{ 
    width: 20em; 
} 
#contactinfo .shorttextbox 
{ 
    width: 5em; 
} 
</style> 

和標記是

<div id="contactinfo"> 
<p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtEmail">Email 
    </asp:Label> 
    <asp:TextBox ID="txtEmail" 
       runat="server" 
       CssClass="longtextbox" /> 
</p> 
<p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtFirstName">First Name 
    </asp:Label> 
    <asp:TextBox ID="txtFirstName" 
       runat="server" 
       ValidationGroup="AccountValidation" /> 
    <asp:RequiredFieldValidator runat="server" 
           ControlToValidate="txtFirstName" 
           Text="First Name is required." 
           ValidationGroup="AccountValidation" 
           CssClass="error"> 
    </asp:RequiredFieldValidator> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtLastName">Last Name 
    </asp:Label> 
    <asp:TextBox ID="txtLastName" 
       runat="server" 
       ValidationGroup="AccountValidation" /> 
    <asp:RequiredFieldValidator runat="server" 
           ControlToValidate="txtLastName" 
           Text="Last Name is required." 
           ValidationGroup="AccountValidation" 
           CssClass="error"> 
    </asp:RequiredFieldValidator> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtBusinessName">Business Name 
    </asp:Label> 
    <asp:TextBox ID="txtBusinessName" 
       runat="server" 
       CssClass="longtextbox" 
       ValidationGroup="AccountValidation" /> 
    <asp:RequiredFieldValidator runat="server" 
           ControlToValidate="txtBusinessName" 
           Text="Business Name is required." 
           ValidationGroup="AccountValidation" 
           CssClass="error"> 
    </asp:RequiredFieldValidator> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtPhone">Phone 
    </asp:Label> 
    <asp:TextBox ID="txtPhone" 
       runat="server" 
       ValidationGroup="AccountValidation" /> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtAddress">Address 
    </asp:Label> 
    <asp:TextBox ID="txtAddress" 
       runat="server" 
       CssClass="longtextbox" 
       ValidationGroup="AccountValidation" /> 
    <asp:RequiredFieldValidator runat="server" 
           ControlToValidate="txtAddress" 
           Text="Address is required." 
           ValidationGroup="AccountValidation" 
           CssClass="error"></asp:RequiredFieldValidator> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="txtCity">City 
    </asp:Label><asp:TextBox ID="txtCity" 
          runat="server" 
          ValidationGroup="AccountValidation" /> 
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" 
      runat="server" 
      ControlToValidate="txtCity" 
      Text="City is required." 
      ValidationGroup="AccountValidation" 
      CssClass="error"> 
    </asp:RequiredFieldValidator> 
    </p> 
    <p> 
    <asp:Label runat="server" 
       AssociatedControlID="ddlState">State 
    </asp:Label> 
    <asp:DropDownList ID="ddlState" 
         runat="server" 
         DataSourceID="dsStates" 
         DataTextField="Name" 
         DataValueField="Id"> 
    </asp:DropDownList> 
    </p> 
    <p> 
    <asp:Label runat="server"     
       AssociatedControlID="txtZipcode">Zipcode</asp:Label> 
       <asp:TextBox ID="txtZipCode" runat="server" CssClass="shorttextbox" 
       ValidationGroup="AccountValidation" /> 

    </p> 
    </div> 

,你可以從上面看,我將每個標籤字段對都包裹在ap標籤中,因此它打破了下一行,但我不確定是否需要這樣做。我希望將城市,州和郵政編碼都放在同一行,但只要將城市,州,郵編的所有標籤和輸入移動到一個p標籤中,就會看起來像下面這樣,但我不知道要解決這個問題。

alt text http://img36.imageshack.us/img36/6417/wantedfn.png

回答

0

編輯:嘗試使用此作爲的CssClass爲 那些標籤 -

#contactinfo noformatlabel 
    { 
     //add here if you need to adjust the spacing..but dont float add padding or     //something else.. 
    padding:0.2em //maybe this if needed for formatting.. 
     } 

我認爲 -

#contactinfo label 
{ 
    float: left; 
    width: 10em; 
    margin-right: 0.5em; 
    text-align: right; 
    font-size: 14px; 
} 

這些CSS屬性的問題.. 。爲城市州的標籤使用不同的css類型和郵政編碼...我的意思是嘗試沒有任何格式化...它可能工作然後..

+0

是的。我認爲這是問題,但我不知道我該怎麼做。我在CSS中不太好。我已經嘗試過改變屬性,但放棄了,因爲我似乎在打敗一場失敗的戰鬥。 – Xaisoft 2010-06-15 19:45:36

+0

看看我的更新迴應是否有幫助.. – Vishal 2010-06-15 19:57:24

+0

好的,我創建了另一個類,就像你說的.noformatlabel,我添加了以下屬性: display:inline; font-size:14px; margin-right:0.5em; text-align:right; 我也在p標籤上放了一個margin-left:8.5em,這樣它的城市就會與其他標籤對齊。起初,這似乎並不奏效,因爲它是從其他標籤樣式繼承而來的,我給了它一個格式標籤的名稱,現在一切看起來都很好。感謝您的正確方向。 – Xaisoft 2010-06-15 21:20:50

0

你可能會浮動這三個輸入以及標籤。或停止浮動標籤,因爲寬度不會像現在這樣。