2012-05-01 48 views
2

我已经从网站上下载了一个.css样式表,其中包含许多表格样式。我想将.css样式表应用于特定的asp.net表格。所以在ASPX我有,如何将CSS应用于特定的asp.net表格?

  <asp:Table cssClass="downloadedCss"> 
      </asp:Table> 

在CSS样式表我下载它有很多东西,如..

  table {} 
      caption{} 
      td, th {} 
      tr {} 
      thead th, tfoot th {} 
      tbody td a {} 
      tbody td a:visited {} 
      tbody td a:hover {} 
      tbody th a {} 
      tbody th a:hover {} 
      tbody td+td+td+td a {} 
      tbody td+td+td+td a:visited {} 
      tbody th, tbody td {} 
      tfoot td {} 
      tbody tr:hover {} 

如何使所有的CSS属性申请只是表(downloadedCss类)

回答

4

ASP.NET表格将呈现为HTML表格。

你的榜样将呈现这样的:

<table class="downloadedCss"> 
</table> 

因此当前的CSS规则都将适用于本表。如果您希望这些样式为,则只有适用于此表格,然后在CSS规则中指定类别名称。

 table.downloadedCss {} 
     table.downloadedCss caption{} 
     table.downloadedCss td, table.downloadedCss th {} 
     table.downloadedCss tr {} 
     table.downloadedCss thead th, table.downloadedCss tfoot th {} 
     table.downloadedCss tbody td a {} 
     table.downloadedCss tbody td a:visited {} 
     table.downloadedCss tbody td a:hover {} 
     table.downloadedCss tbody th a {} 
     table.downloadedCss tbody th a:hover {} 
     table.downloadedCss tbody td+td+td+td a {} 
     table.downloadedCss tbody td+td+td+td a:visited {} 
     table.downloadedCss tbody th, table.downloadedCss tbody td {} 
     table.downloadedCss tfoot td {} 
     table.downloadedCss tbody tr:hover {} 
+0

感谢您的帮助! – lawphotog

2

如果更改

table {} 

table.downloadedCss {} 

然后所有其他样式,然后将只适用于那些该表之前添加。例如

table.downloadedCss caption {} 
table.downloadedCss td, th {} 

但是我可能会去掉很多的CSS,因为我怀疑你会需要所有这些。

+0

感谢您的帮助! – lawphotog

1
<table CssClass="pnlstudentDetails"> 
     <tr> 
      <td> 
      </td> 
     </tr> 
    </table> 

To apply Css for all the td elements under the specific table or panel or div try this code . 
.pnlstudentDetails td 
     { 
      height: 40px; 
      vertical-align: middle; 
      text-align: left; 
      margin-top: 10px; 
     } 
相关问题