ASP.Net垂直对齐面板中的控件

时间:2009-11-05 22:04:54

标签: asp.net alignment vertical-alignment

我有一个小组,其中包含以下内容:

<asp:Panel ID="Panel1" runat="server" Height="101px">
    Day
    <asp:DropDownList ID="DropDownList1" runat="server" Height="24px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
    </asp:DropDownList>
    &nbsp;Hour
    <asp:DropDownList ID="DropDownList2" runat="server">
    </asp:DropDownList>
</asp:Panel>

文本(“日”和“小时”)似乎与下拉框有不同的垂直对齐

alt text http://img215.imageshack.us/img215/115/paneld.jpg

如何轻松解决此问题?

7 个答案:

答案 0 :(得分:2)

我偶然发现的一个解决方案是将文本和DropDownLists包含在一个包含单行的表中,并为每个文本/保管箱添加一个单独的单元格。像魅力一样。

答案 1 :(得分:1)

这真的很简单:

<div>
    Day
    <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList>
    Hour
    <asp:DropDownList ID="DropDownList2" runat="server">
    </asp:DropDownList>
</div>

答案 2 :(得分:1)

不确定你是否尝试过这个......

<div style="vertical-align:top"> 
    Day 
    <asp:DropDownList ID="DropDownList1" runat="server" style="vertical-align:bottom"> 
    </asp:DropDownList> 
    Hour 
    <asp:DropDownList ID="DropDownList2" runat="server" style="vertical-align:bottom"> 
    </asp:DropDownList>  
</div>

答案 3 :(得分:0)

您是否尝试使用样式属性调整垂直对齐? http://www.w3schools.com/Css/pr_pos_vertical-align.asp

答案 4 :(得分:0)

尝试将标记形成为或在其周围添加一些空格。它可能是包装。

答案 5 :(得分:0)

其他答案有格式问题。这是它。

不确定你是否尝试过:

<div style="vertical-align:top"> 
  Day 
  <asp:DropDownList ID="DropDownList1" runat="server" style="vertical-align:bottom"> 
  </asp:DropDownList> 
   Hour 
  <asp:DropDownList ID="DropDownList2" runat="server" style="vertical-align:bottom"> 
   </asp:DropDownList> 
</div>

答案 6 :(得分:0)

如果你没有

,试试这个
<div style="vertical-align:top">
Day 
<asp:DropDownList ID="DropDownList1" runat="server" style="vertical-align:bottom">
</asp:DropDownList>
Hour 
<asp:DropDownList ID="DropDownList2" runat="server" style="vertical-align:bottom>
</asp:DropDownList>
</div>