0

我需要为我的每个 asp:table 列添加右边框(我有 3 个跨栏)。以下代码适用于表格,但仅在整个表格周围放置边框:

style="border-left: 3px solid blue; border-right: 3px solid blue"

如何将其添加到列并定义自定义颜色?

4

3 回答 3

2

pOcHa 为所有分配了类的表获得了它。

要为特定的命名表定义样式,您可以使用 ID 选择器:

/* Just named tables */
#Table1 td{ border-right:2px solid #00F;}

CSS 文件:

/* All tables */
table td{ border-right:2px solid #00F;}

/* All tables with Rightborders class */
table.Rightborders td{ border-right:2px solid #00F;}

/* Just named tables */
#Table1 td{ border-right:2px solid #00F;}

代码:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Table ID="Table1" CssClass="Rightborders" runat="server">
        <asp:TableRow>
        <asp:TableCell>1</asp:TableCell>
        <asp:TableCell>2</asp:TableCell>
        <asp:TableCell>3</asp:TableCell>
        </asp:TableRow>
        </asp:Table>
    </div>
    </form>
</body>
</html>

-J

于 2012-06-02T16:51:10.360 回答
1

只需将一个RightBordersCSS 类添加到您的表中,然后像这样定义它:

table.RightBorders td { border-right: 1px solid "custom color" }
于 2012-06-02T15:55:23.207 回答
0
<style type="text/css">
    .tablecell
    {
        border-right:3px solid #bbb;
    }
</style>


<asp:Table ID="Table1" runat="server">
    <asp:TableRow>
        <asp:TableCell CssClass="tablecell">c1</asp:TableCell>
        <asp:TableCell CssClass="tablecell">c2</asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell CssClass="tablecell">c1</asp:TableCell>
        <asp:TableCell CssClass="tablecell">c2</asp:TableCell>
    </asp:TableRow>
</asp:Table>
于 2012-06-02T17:27:25.240 回答