我有两个面板。我想并排展示它们,但它们没有。
.aspx:
<asp:Panel ID="treeviewMenu" Width="20%" Height="500" runat="server" ScrollBars="Both" HorizontalAlign="Left">
<asp:TreeView ID="treeview" runat="server" ShowLines="True" ImageSet="XPFileExplorer" OnSelectedNodeChanged="treeview_SelectedNodeChanged">
</asp:TreeView>
</asp:Panel>
<asp:Panel ID="qvObjektMenu" Width="75%" Height="500" runat="server" HorizontalAlign="Right">
<asp:Table runat="server" HorizontalAlign="Right">
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server">
QVObjekt Id:
</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:Label ID="qvObjektId" runat="server"></asp:Label>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:Panel>
我在这两个元素之外使用了一个表格,在它们周围使用了另一个面板,但没有任何效果。 我该如何解决这个问题?
最佳答案
这里的答案是 CSS。关于如何在 CSS 中执行此操作,有几个选项。
选项 1:display:inline-block;
该 css 的一个选项是使用 display: inline-block;
:
<style type="text/css">
.inlineBlock { display: inline-block; }
</style>
再加上在 <asp:Panel ...>
中设置它标签:
<asp:Panel ID="treeviewMenu" ... CssClass="inlineBlock">
...
</asp:Panel>
<asp:Panel ID="qvObjektMenu" ... CssClass="inlineBlock">
...
</asp:Panel>
选项 2a:float:left;
另一种选择,如 Wim's answer 中所述就是用花车。但我不认为你想把两个面板组合起来有 float ——我怀疑你只想要一个或另一个。要么:
<style type="text/css">
.floatLeft { float: left; }
</style>
和
<asp:Panel ID="treeviewMenu" ... CssClass="floatLeft">
<asp:TreeView ID="treeview" runat="server" ShowLines="True" ImageSet="XPFileExplorer" >
</asp:TreeView>
</asp:Panel>
(与当前在您的标记中的其他面板一起使用)
或
选项 2b:float:right;
<style type="text/css">
.floatRight { float: right; }
</style>
和
<asp:Panel ID="qvObjektMenu" ... CssClass="floatRight">
...
</asp:Panel>
关于c# - 我怎样才能显示两个asp :Panel controls side by side?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16544402/