单个 HtmlRow 周围的边框

发布于 2024-12-04 18:01:08 字数 1282 浏览 7 评论 0原文

我正在尝试在 C# 中仅向一个 HtmlRow 添加边框。该行位于边缘有边框的表格中。我已经尝试过:

row.Attributes.Add("border-bottom", "1px");
row.Attributes.Add("border-color", "#000000");
row.Attributes.Add("border-style", "solid");
row.Style.Add("border-width", "1px");
row.Style.Add("border-color", "#000000");
row.Style.Add("border-style", "solid");
row.BorderColor = "#000000";

行的结果 html:

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">
    <td width="25px" align="center"><FONT COLOR=#000000>Last</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>First</FONT></td>
    <td align="center" width="100px"><FONT COLOR=#000000>Address</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>Phone</FONT></td>
</tr>

但这些都不起作用。我无法使用表格来制作边框,因为该行正在用于对后续行进行建模。另外,如果这更容易,我只需要行的底部有一个边框。

I am trying to add a border to just one HtmlRow in C#. The row is going in a table that has a border around it's edge. I have tried:

row.Attributes.Add("border-bottom", "1px");
row.Attributes.Add("border-color", "#000000");
row.Attributes.Add("border-style", "solid");
row.Style.Add("border-width", "1px");
row.Style.Add("border-color", "#000000");
row.Style.Add("border-style", "solid");
row.BorderColor = "#000000";

resulting html for the row:

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">

<tr class="tableHeader" Style="height:30px;border-width:1px;border-color:#000000;border-style:solid;" border-bottom="1px" border-color="#000000" border-style="solid" bordercolor="#000000">
    <td width="25px" align="center"><FONT COLOR=#000000>Last</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>First</FONT></td>
    <td align="center" width="100px"><FONT COLOR=#000000>Address</FONT></td>
    <td width="50px" align="center"><FONT COLOR=#000000>Phone</FONT></td>
</tr>

But none of these have worked. I cannot use a table to make the border because the row is being used to model subsequent rows. Also, if this makes it easier, I only need the bottom of the row to have a border.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甩你一脸翔 2024-12-11 18:01:09

您可能应该将样式放入样式表中并使用类。它还将使您更容易测试,因为您只需要在运行时添加样式,而不是创建所需效果的每个元素。

这个怎么样 http://jsfiddle.net/yQbTp/1/

<table id="border">
    <tr>
        <td>apple</td>
        <td>banana</td>
    </tr>
    <tr class="border">
        <td>cherry</td>
        <td>date</td>
    </tr>
    <tr>
        <td>egg</td>
        <td>fruit</td>
    </tr>
    <tr>
        <td>grape</td>
        <td>ham</td>
    </tr>
</table>
table#border{
    width:100%;
    border:1px solid black;
}
table#border tr.border{
    border:1px solid red;
}
table#border tr:last-child{
    border:1px solid green;
}

you should probably looking to put the style in a style sheet and use a class. it will also make it easier for you to test as you just need to add the style at run time and not each element that create the desired effect.

how about this http://jsfiddle.net/yQbTp/1/

<table id="border">
    <tr>
        <td>apple</td>
        <td>banana</td>
    </tr>
    <tr class="border">
        <td>cherry</td>
        <td>date</td>
    </tr>
    <tr>
        <td>egg</td>
        <td>fruit</td>
    </tr>
    <tr>
        <td>grape</td>
        <td>ham</td>
    </tr>
</table>
table#border{
    width:100%;
    border:1px solid black;
}
table#border tr.border{
    border:1px solid red;
}
table#border tr:last-child{
    border:1px solid green;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文