【问题标题】:how to set width,height etc to particular table in html如何在html中为特定表格设置宽度、高度等
【发布时间】:2013-02-21 11:51:15
【问题描述】:

我有一个必须设置高度和宽度以及边框的表格。我已经尝试过这个 css

table,td,tr#cer_actuals {
    padding-left: 5px;
    font-family: Verdana;
    font-size: 9pt;
    font-weight: normal;
    height: 0px;
    border: 1px solid grey;
}

这会影响项目中的所有表,所以我尝试了这个,

#cer_actuals {
    padding-left: 5px;
    font-family: Verdana;
    font-size: 9pt;
    font-weight: normal;
    height: 0px;
    border: 1px solid grey;
}

和 HTML

<table  width="100%" id="cer_actuals" > 
<tr>
                                                <td align="left" width="10%"  style="background-color:#f1e0ff;"></td>
                                                <td align="center" width="20%" style="background-color:#f1e0ff;">
                                                    Mth
                                                </td>
                                                <td align="center" width="30%" style="background-color:#f1e0ff;">
                                                    Actuals
                                                </td>
                                                <td align="center" width="40%" style="background-color:#f1e0ff;">
                                                    EOY Accruals
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="left" width="10%"  style="background-color:#f1e0ff;"></td>
                                                <td align="center" width="20%" style="background-color:#f1e0ff;">C/F</td>
                                                <td  align="center" width="30%" style="background-color:white;">
                                                            <input type="text" id="CIMtrek_CI_Act_CF" name="CIMtrek_CI_Act_CF">
                                                                <xsl:attribute name="value"><xsl:value-of
                                                                    select="//Record/CIMtrek_CI_Act_CF/text()" /></xsl:attribute>
                                                            </input>
                                                </td>
                                                <td  align="center" width="40%" style="border-width:1px 0px 0px 1px;">

                                                </td>
                                            </tr>

但这对桌子没有影响。

我必须为表格中的 td 设置高度。

如何做到这一点。

请帮忙。

【问题讨论】:

  • 我认为你应该指定“一些内容”,因为这样,“一些内容”不在表格上下文中。也需要 tr 和 td 标签。

标签: html css html-table


【解决方案1】:

这样做

#cer_actuals td {
    padding-left: 5px;
    font-family: Verdana;
    font-size: 9pt;
    font-weight: normal;
    height: 0px;
    border: 1px solid grey;
}

DEMO

【讨论】:

    【解决方案2】:

    添加这个:

    #cer_actuals td {
      height: 0px;
    }
    

    【讨论】:

      【解决方案3】:

      这样做 -

      <table cellpadding="0" cellspacing="0" border="0" align="center" width="100%">
          <tr>
              <td>Some Content</td>
          </tr>
          <tr>
              <td>Some Content</td>
          </tr>
      </table>
      

      CSS

      table td{
        padding: 5px;
      }
      

      【讨论】:

        【解决方案4】:

        请尝试:

        cer_actuals tr td {...}

        "#cer_actuals - 表示所有 id = cer_actuals 的元素; tr - 表示我们之前得到的所有表格行 td - 表示我们之前得到的所有 td"

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-05-24
          • 1970-01-01
          • 2021-10-08
          • 2020-06-11
          • 1970-01-01
          • 2011-09-23
          • 1970-01-01
          相关资源
          最近更新 更多