asp.net - 使用未完全填满面板的内容设置面板高度

标签 asp.net css

我有两个面板,它们的高度必须相同。面板的代码如下:

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

相关文章:

javascript - 如何使用vanilla js使页面在点击导航链接时滚动到某个位置,应该也很流畅

asp.net - 从 ASP.NET 获取动态创建的标签 (jQuery)

javascript - 使用 JavaScript 操作 Razor 模型

C# ASP.NET : Dynamically constructing an url query string

.net - 在 ASP.NET 应用程序中存储临时数据的位置

html - CSS - flex 问题

JavaScript 或 CSS 无法在 Internet Explorer 上运行

html - 如何去除网站的空白区域?

javascript - 服务器控件中 JavaScript 函数的范围

Css 无法与 ejs 模板引擎一起快速工作