ASPX 页面上的格式问题
场景:我想通过 ASPX 页面显示以下内容
State : <dropdown>
zip : <textbutton>
请注意,“:”代表 State &所有线路中的城市应该相同。目前我得到了下面的东西。
State : <dropdown>
zip : <textbutton>
我一定做错了什么,但还不知道。感谢任何输入,
这是到目前为止我的代码,
<div style="text-align:center" >
<asp:Label runat="server" id="StateCategory" Text ="State:" CssClass="LabelLeftAligned" />
<asp:DropDownList runat="server" ID="StateDDown" DataTextField="Name" AppendDataBoundItems="true"></asp:DropDownList>
</div>
<div style="text-align:center" >
<asp:Label runat="server" id="lblzipCode" Text ="Zip:" CssClass="LabelLeftAligned" />
<asp:TextBox ID="txtboxZipcode" runat="server" MaxLength="5" />
</div>
类 LabelLeftAligned 在样式表中定义如下。
.LabelLeftAligned {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: black;
font-weight: bold;
text-align: left;
}
Scenario: I want to display the following through ASPX page
State : <dropdown>
zip : <textbutton>
Note that the ":" for both State & City should be same in all lines. Currently I am getting something below.
State : <dropdown>
zip : <textbutton>
I must be doing something wrong but don't know yet. Appreciate any inputs,
Here is my code so far,
<div style="text-align:center" >
<asp:Label runat="server" id="StateCategory" Text ="State:" CssClass="LabelLeftAligned" />
<asp:DropDownList runat="server" ID="StateDDown" DataTextField="Name" AppendDataBoundItems="true"></asp:DropDownList>
</div>
<div style="text-align:center" >
<asp:Label runat="server" id="lblzipCode" Text ="Zip:" CssClass="LabelLeftAligned" />
<asp:TextBox ID="txtboxZipcode" runat="server" MaxLength="5" />
</div>
and the class LabelLeftAligned is defined below in the stylesheet.
.LabelLeftAligned {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: black;
font-weight: bold;
text-align: left;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将标签变成块级元素,给它一个宽度并右对齐。
类似于:(完整示例)
示例如下:
Turn the label into a block level element, give it a width and right align it.
Something like: (full example)
example below:
您可以使用 CSS 中的表格格式来实现此目的。您可以对行和单元格使用
layout
,并使用text-align
来控制水平对齐方式。点击此处进行工作演示。
You can use table formatting in CSS to achieve this. You would use
layout
for your rows and cells, andtext-align
to control the horizontal alignment.Click here for a working demonstration.
根据我所看到的一点点,将数据表化,在这种情况下应该不是问题
,或者
将状态和 zip 包装在 div 中,然后将其向左浮动,并留有宽度
either table the data which in this case shouldn't be a problem based on the little bit I am seeing
OR
wrap the state and zip in a div and then float it left with a width on it