【问题标题】:Can't change row height in asp.net table无法更改 asp.net 表中的行高
【发布时间】:2023-03-21 14:45:01
【问题描述】:

这是我在表格中的第一行:

<table style="margin:auto; border-color:Black;" border="1">
    <tr style="color:White; background-color:Maroon; height:50%;">
        <td colspan ="2" align="center"><h3>aaa</h3></td>
    </tr>
    <tr>
        <td align="right" style="width:150px;">bbb</td>
        <td style="width:150px;">
            <asp:Label ID="lblKSParterObicna" runat="server" Text="Label"></asp:Label>
        </td>
    </tr>
</table>

现在我想更改第一行的高度,但是我为属性“高度”设置了什么 它总是一样的。 有人知道如何改变它吗?

【问题讨论】:

标签: asp.net visual-studio-2010 html-table


【解决方案1】:

用 CSS 试试,

table > tr:first-child td {
height:#px }

【讨论】:

    【解决方案2】:

    它不起作用的原因是因为您的第一行中有标签。所以我发现的是: 1. 使用百分比作为高度不起作用(有或没有标签)(不知道为什么) 2. 如果您将标签保留在第一行,只要高度大于标签给出的默认高度,使用像 200px 这样的单位就可以了。如果您删除标签,任何以 px 为单位的单位都可以使用(只要字体大小适合它)。

    这是下面代码的 jsfiddle:http://jsfiddle.net/yMKAr/3/

    <table style="margin:auto; border-color:Black;" border="1">
        <tr style="color:White; background-color:Maroon; height:200px">
            <td colspan ="2" align="center"><h3>aaa</h3></td>
        </tr>
        <tr>
            <td align="right" style="width:150px;">bbb</td>
            <td style="width:150px;">
                Label
            </td>
        </tr>
    </table>
    

    【讨论】:

    • 当然,更好的选择是创建一个 css 文件来放置格式 - 保持格式一致更容易。
    【解决方案3】:

    你能检查一下这个吗? http://jsfiddle.net/DwzA6/

     <div style="height:200px;" >
        <table style="margin:auto; border-color:Black; height:100%;" border="1">
            <tr style="color:White; background-color:Maroon; height: 80%;">
                <td colspan ="2" align="center"><h3>aaa</h3></td>
            </tr>
            <tr>
                <td align="right" style="width:150px;">bbb</td>
                <td style="width:150px;">
                    <asp:Label ID="lblKSParterObicna" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
         </table>
        </div>
    

    在您的情况下,您还没有定义 桌子的高度。所以这就是为什么你没有看到你的第一行有任何变化的原因。 要么以像素为单位保持表格的高度,要么在表格外创建一个固定高度的 div,然后以 % 为单位设置第一行和表格的高度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多