-2

我有以下标签和文本框 -

<div>

 <fieldset class="myform">
   <legend>Form</legend>

   <asp:Label ID="Label1" runat="server" AssociatedControlID="fname">First Name:</asp:Label>
   <asp:TextBox ID="fname" runat="server" CssClass="textEntry"></asp:TextBox> <br>

   <asp:Label ID="Label2" runat="server" AssociatedControlID="lname">Last Name:</asp:Label>
   <asp:TextBox ID="lname" runat="server" CssClass="textEntry"></asp:TextBox> <br>

   <asp:Label ID="Label3" runat="server" AssociatedControlID="town">Address1:</asp:Label>
   <asp:TextBox ID="address1" runat="server" CssClass="textEntry"></asp:TextBox> <br>

   <asp:Label ID="Label5" runat="server" AssociatedControlID="town">Town:</asp:Label>
   <asp:TextBox ID="town" runat="server" CssClass="textEntry"></asp:TextBox> <br>

  </fieldset>

 </div>

输出是标签-(fname,lname,address等)很好地排列而文本框不是,我想做的是让文本框排列起来?

非常感谢任何帮助,谢谢

所以我想要这样

 First Name  [          ]
  Last Name  [          ]
    Address  [          ]

等等

4

2 回答 2

0

您在代码中添加一个类labels

  <div>

 <fieldset class="myform">
 <legend>Form</legend>

 <asp:Label ID="Label1" class="labels" runat="server" AssociatedControlID="fname">First   Name:</asp:Label>
 <asp:TextBox ID="fname" runat="server" CssClass="textEntry"></asp:TextBox> <br>

 <asp:Label ID="Label2" class="labels" runat="server" AssociatedControlID="lname">Last Name:</asp:Label>
 <asp:TextBox ID="lname" runat="server" CssClass="textEntry"></asp:TextBox> <br>

 <asp:Label ID="Label3" class="labels" runat="server" AssociatedControlID="town">Address1:</asp:Label>
 <asp:TextBox ID="address1" runat="server" CssClass="textEntry"></asp:TextBox> <br>

 <asp:Label ID="Label5" class="labels" runat="server" AssociatedControlID="town">Town:     </asp:Label>
 <asp:TextBox ID="town" runat="server" CssClass="textEntry"></asp:TextBox> <br>

</fieldset>

</div>​​​

那么你的CSS可能是这样的。

.myform {text-align:right;width:300px; }
.labels {padding-right:10px;}
于 2012-11-30T15:50:48.193 回答
0

使用您的样式。

在你的 CSS 类型中

.textEntry {left:20px;}

20是随机数;您可以根据需要进行调整。这将导致您的所有文本框与左侧的特定距离对齐

于 2012-11-30T15:04:26.923 回答