我有两个面板,它们的高度必须相同。面板的代码如下:
<asp:Panel ID="Panel1" GroupingText="Material" CssClass="material"
runat="server" >
<asp:RadioButtonList ID="RadioButtonList1" runat="server" >
<asp:ListItem Selected="True">Plastics</asp:ListItem>
<asp:ListItem Enabled="false">Glass</asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
<asp:Panel ID="Panel2" GroupingText="Material" CssClass="design"
runat="server" >
<asp:RadioButtonList ID="RadioButtonList1" runat="server" >
<asp:ListItem >SV</asp:ListItem>
<asp:ListItem ">Bifocal</asp:ListItem>
<asp:ListItem >Varifocal</asp:ListItem>
<asp:ListItem >Intermediate</asp:ListItem>
</asp:RadioButtonList>
</asp:Panel>
我用下面的 CSS 为这两个面板设置了样式:
.material{display:inline-block; float:left;max-height:200px;width:90px;overflow:hidden;}
.design {display:inline-block; float:left;max-height:200px;width:210px;overflow:hidden;}
请注意,我尝试使高度相同。然而,由于 panel1 的内容很少,因此面板的边框一直延伸到 200px 的高度。即使内容没有完全填满面板,我怎么能有相同的高度。
最佳答案
asp.net 中的面板在以 HTML 呈现时不会呈现为面板,因为面板不是有效的 html 标记。 您可以将 div 包装在面板内并为 div 提供样式。
<asp:Panel ID="Panel1" GroupingText="Material" CssClass="material"
runat="server" >
<div class="material">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" >
<asp:ListItem Selected="True">Plastics</asp:ListItem>
<asp:ListItem Enabled="false">Glass</asp:ListItem>
</asp:RadioButtonList>
</div>
</asp:Panel>
<asp:Panel ID="Panel2" GroupingText="Material" CssClass="design"
runat="server" >
<div class="design">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" >
<asp:ListItem >SV</asp:ListItem>
<asp:ListItem ">Bifocal</asp:ListItem>
<asp:ListItem >Varifocal</asp:ListItem>
<asp:ListItem >Intermediate</asp:ListItem>
</asp:RadioButtonList>
</div>
</asp:Panel>
关于asp.net - 使用未完全填满面板的内容设置面板高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18058651/