C# asp.net 表格边框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10862800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 15:34:28  来源:igfitidea点击:

asp.net Table borders

c#asp.netborder

提问by sd_dracula

I need to add Right borders to each of my asp:table columns (I have 3 going across). The following code is for the table but it only places borders around the whole table:

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

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

How to add it to columns and also define a custom colour?

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

采纳答案by MTAdmin

pOcHa got it for all tables with a class assigned .

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

To define styles for specific named tables you would use the ID Selector:

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

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

CSS file:

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;}

Code:

代码:

<%@ 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

-J

回答by Nikola Bogdanovi?

Just add a RightBorderscss class to your table, and define it like this:

只需RightBorders在表中添加一个css 类,然后像这样定义它:

table.RightBorders td { border-right: 1px solid "custom color" }

回答by Darshana

<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>