似乎没风格?

时间:2012-04-19 14:03:55

标签: html html-table

简单的CSS:

table.tgi
{
    width:100%;
}

table.tgi td.labelcell
{
    text-align:right;
    color:Red;
}

table.tgi td.valuecell
{
    text-align:left;
    color:Green;
}

简单的HTML:

<table id="tgi" runat="server" width="100%">
            <tbody>
            <tr>
                <td class="labelcell">ID:</td>
                <td></td>
                <td class="labelcell">Originator:
                </td>
                <td class="valuecell"><asp:Button ID="Button1" runat="server" Text="Button" /></td>
            </tr>
            <tr>
                <td class="labelcell">Expected Ship Date:</td>
                <td class="valuecell"><asp:TextBox ID="txtExpectedShipDate" runat="server"></asp:TextBox></td>
                <td class="labelcell">Actual Ship Date:</td>
                <td class="valuecell"><asp:TextBox ID="txtActualShipDate" runat="server"></asp:TextBox></td>
            </tr>
            </tbody>
        </table>

但TD造型不起作用......

修改

我试过了:

table#tgi
{
    width:100%;
}

table#tgi td.labelcell
{
    text-align:right;
    color:Red;
}

table#tgi td.valuecell
{
    text-align:left;
    color:Green;
}

使用HTML:

 <table id="tgi" runat="server">
            <tbody>
            <tr>
                <td class="labelcell">ID:</td>
                <td class="valuecell"></td>
                <td class="labelcell">Originator:</td>
                <td class="valuecell"><asp:Button ID="Button1" runat="server" Text="Button" /></td>
            </tr>
            <tr>
                <td class="labelcell">Expected Ship Date:</td>
                <td class="valuecell"><asp:TextBox ID="txtExpectedShipDate" runat="server"></asp:TextBox></td>
                <td class="labelcell">Actual Ship Date:</td>
                <td class="valuecell"><asp:TextBox ID="txtActualShipDate" runat="server"></asp:TextBox></td>
            </tr>
            </tbody>
        </table>

这不起作用...... 但是如果我把它改成一个类就可以了......但是我想尝试用ID ???

3 个答案:

答案 0 :(得分:1)

你的表有一个ID,如果tgi,而不是一个类。

修复#1

<table class="tgi" runat="server" width="100%">

修复#2

table#tgi
{
    width:100%;
}

table#tgi td.labelcell
{
    text-align:right;
    color:Red;
}

table#tgi td.valuecell
{
    text-align:left;
    color:Green;
}

答案 1 :(得分:0)

由于tgi是表标签上的一个类,因此你的选择器必须是table#tgi。请参阅css standard for more info on selectors.

答案 2 :(得分:0)

你是选择者的状态:

table.tgi

这意味着tabletgi

您的表没有此类,但它的值为ID。要选择ID,您需要使用#代替.

table#tgi

-- SEE EXAMPLE --