gpt4 book ai didi

html - asp.net 表格高度不变

转载 作者:行者123 更新时间:2023-11-28 17:47:39 24 4
gpt4 key购买 nike

我有一个带有静态数据的简单 asp:Table 控件。表格的行高太高,所以我想将它们设置得更窄。我设置了 Height 属性,但表格的高度没有改变。 html 如下:

<asp:Table ID="TextTable" runat="server" BorderColor="Black" BorderStyle="Solid" CellPadding="10" GridLines="Both" HorizontalAlign="Center" Width="234px">

<asp:TableHeaderRow HorizontalAlign="Center" Font-Bold="True" Height="15px">
<asp:TableHeaderCell>Folder Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Files Created</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableRow runat="server" HorizontalAlign="Center" Height="10px">
<asp:TableCell runat="server">CJON</asp:TableCell>
<asp:TableCell runat="server">8</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" HorizontalAlign="Center" Height="10px">
<asp:TableCell runat="server">Forum</asp:TableCell>
<asp:TableCell runat="server">8</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" HorizontalAlign="Center" Height="10px">
<asp:TableCell runat="server">Connect</asp:TableCell>
<asp:TableCell runat="server">4</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server" HorizontalAlign="Center" Height="10px">
<asp:TableCell runat="server">Count</asp:TableCell>
<asp:TableCell runat="server">1</asp:TableCell>
</asp:TableRow>
</asp:Table>

如何设置行和标题行的高度?

最佳答案

您必须为 <th> 设置高度和填充和 <td>以及。如果你在 css 中这样做会更好。以下是我的做法:

标记:

<asp:TableHeaderRow HorizontalAlign="Center" Font-Bold="True" CssClass="myHeight15">
<asp:TableHeaderCell>Folder Name</asp:TableHeaderCell>
<asp:TableHeaderCell>Files Created</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableRow ID="TableRow1" runat="server" HorizontalAlign="Center" CssClass="myHeight10">
<asp:TableCell ID="TableCell1" runat="server">CJON</asp:TableCell>
<asp:TableCell ID="TableCell2" runat="server">8</asp:TableCell>
</asp:TableRow>
... ... ...

还有我的 head 部分的 CSS:

<head runat="server">
<title></title>
<style>
.myHeight15 {
height: 15px;
}
.myHeight15 th{
height: 15px;
padding:0px;
}
.myHeight10 {
height: 10px;
}
.myHeight10 td{
height: 10px;
padding:0px;
}
</style>
</head>

关于html - asp.net 表格高度不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22939657/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com