【发布时间】:2011-05-02 12:10:42
【问题描述】:
可能的重复:
How to alternate HTML table row colors using JSP?
Table row - Giving alternate colors
谁能提供在jsp文件中使用CSS在表格中动态添加行的基本代码,请提供此代码?
【问题讨论】:
标签: html css jsp dynamic html-table
可能的重复:
How to alternate HTML table row colors using JSP?
Table row - Giving alternate colors
谁能提供在jsp文件中使用CSS在表格中动态添加行的基本代码,请提供此代码?
【问题讨论】:
标签: html css jsp dynamic html-table
<table>
<?
boolean evenRow = true;
for (int i = 0; i < numRowsToDisplay; i++)
{
?>
<tr class="<?= evenRow? "evenrowstyle" : "oddrowstyle" ?>"><td>whatever</td></tr>
<?
evenRow = !evenRow;
}
?>
</table>
【讨论】:
基本上有两种选择:
【讨论】:
【讨论】:
如
<style>
#TableID tr:nt-child(odd){
background-color:white;
}
#TableID tr:nth-child(even){
background-color:silver;
}
</style>
【讨论】: