2009-11-05 75 views
1

我有以下內容的面板:ASP.Net垂直取向

<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> 

的文本(「日」和「小時」)似乎有相對於所述不同的垂直取向dropdownboxes

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

如何輕鬆地解決這個問題?

+0

在Panel1的設置垂直對齊方式使用文本的頂部,以'風格=「vertical-align:text-top;」'屬性。 – devstuff 2009-11-06 02:45:38

+0

我知道我以前見過這種情況,但現在我無法用您的代碼片段重現它。另外,你是否有意設置面板的高度並下降?如果沒有,你可以刪除它們。 – Greg 2009-11-06 13:18:43

回答

0

您是否嘗試過使用樣式屬性調整垂直對齊? http://www.w3schools.com/Css/pr_pos_vertical-align.asp

+0

這些是ASP.Net控件,我不知道如何在這些上應用CSS樣式。 – Nikhil 2009-11-05 23:18:43

+0

@Nikhil:添加一個'style =「...」'屬性。你不會得到它的Intellisense,但它會正確呈現。儘管您最好使用CssClass屬性並將樣式放入樣式表中,而不是內聯樣式。 – devstuff 2009-11-06 02:44:00

+0

嘗試過'樣式'出來,但即使嘗試不同的對齊選項後,我也無法正確對齊。 – Nikhil 2009-11-07 01:35:01

1

這真是這個簡單:

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

這也不起作用。 – Nikhil 2009-11-06 22:08:07

+0

你真的嘗試過div嗎?如果是這樣,我們給了你什麼瀏覽器給你這個問題? – IrishChieftain 2011-03-28 22:31:45

0

嘗試形成你的標籤,或添加它們周圍的一些空白。它可能是包裝。

2

我偶然發現的一個解決方案是將文本和DropDownLists放在一個表格中,並且每行都有一個單獨的單元格。奇蹟般有效。

+0

爲什麼使用表格時,SEO友好的標記就像簡單和免費一樣? – IrishChieftain 2009-11-06 15:04:12

+1

不!請不!表格佈局是如此1991. – 2009-11-06 15:04:53

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> 
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> 
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> 
+1

不知何故,div的風格屬性在FF和Chrome中不起作用。如果是這種情況,請嘗試垂直對齊單個元素。 – coHobo 2012-03-22 23:24:57