我正在寻找一种直接的 css 解决方案,它将强制标签与它们在 asp 中的控件顶部对齐。例如:
<asp:Label runat="server" AssociatedControlID="cboBox" Text="Control Label" />
<asp:DropDownList runat="server" ID="cboBox" />
会出现这样的东西:
Control Label
[[[[[]]]]]]]]]]]]V
有什么想法吗?
最佳答案
将它们都包裹在一个 span 或 div 中:
<span class="field">
<asp:Label runat="server" AssociatedControlID="cboBox" Text="Control Label" />
<asp:DropDownList runat="server" ID="cboBox" />
</span>
然后:
.field label,
.field select
{
display: inline-block;
vertical-align: top;
/* achieves same as inline-block for IE7 */
*display: inline;
*zoom: 1;
}
关于asp.net - 有没有一种可靠的方法可以使标签与其控件顶部对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9945632/