我需要为每个asp:table列添加右边框(我有3个遍历)。 以下代码适用于表,但它只在整个表中放置边框:
style="border-left: 3px solid blue; border-right: 3px solid blue"
如何将其添加到列中并定义自定义颜色?
答案 0 :(得分: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
答案 1 :(得分:1)
只需在表格中添加RightBorders
css类,并按以下方式定义:
table.RightBorders td { border-right: 1px solid "custom color" }
答案 2 :(得分: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>