我有以下标签和文本框 -
<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 [ ]
等等
答案 0 :(得分:0)
使用你的造型。
在您的css类型中
.textEntry {left:20px;}
20是随机数;您可以根据需要进行调整。这将导致您的所有文本框在距离左侧特定距离处对齐
答案 1 :(得分: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;}