2014-09-29 60 views
0

我創建使用代碼behind.I的HTMLTABLE的PDF已經通過線如何刪除單元格和Html表格的行之間的邊界?

HtmlTable table1 = new HtmlTable(); 
table1.Attributes.Add("border", "1"); 

這創造了細胞與行之間也邊框設置邊框的表格。我能做些什麼如果我只需要頂部和底部的邊框?

我試過下面的code.but我沒有工作。

table1.Attributes.Add("border-top", "solid"); 
table1.Attributes.Add("border-bottom", "solid"); 

請幫助我的人。

如何只設置HtmlTable的頂部和底部邊框?

回答

1

table元素上的border屬性的確設置了所有單元格的邊界。因此,您可以嘗試設置border-topborder-bottom,但由於它們是CSS屬性而不是HTML屬性,因此不能直接在元素上設置它們。取而代之的是,它們可以與一個HTML style屬性進行設置:

table1.Attributes.Add("style", "border-top: solid; border-bottom: solid"); 

然而,這產生了與medium(通常爲兩個像素)的瀏覽器依賴性寬度邊界。如果你想要一個像素的邊框,設置

table1.Attributes.Add("style", "border-top: solid 1px; border-bottom: solid 1px"); 
0

你可以通過CSS解決這個問題。

演示:Jsfiddle

table{ 
width:400px; 
margin:0 auto; 
background:#4679BD; 
border-top:1px solid red; 
border-bottom:1px solid red; 
} 
相關問題