我认为代码将“Rank”标题计为一行并为其分配1。如何更改 的第一个数字counter-increment
?我希望表格从 0 开始,以便将“Rank”标题分配为 0,下一行为 1,依此类推。
http://oi59.tinypic.com/5bsabc.jpg
CSS 文件
tr.odd {background-color: #FFFFFF}
tr.even {background-color: #F2F2F2}
table {
counter-reset: rowNumber;
}
table tr {
counter-increment: rowNumber;
}
table tr td:first-child::before {
content: counter(rowNumber);
min-width: 1em;
text-align: center;
}
JSP 文件
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<c:url value='/css/egovframework/leaderboard.css'/>" />
<form id="listForm" name="listForm" method="post">
<input type="hidden" name="id"/>
</form>
<h1 style="text-align:center;font-size:56px; font-family: Mistral;margin-top:-45px;">Leaderboard</h1>
<body style="font-family:Arial;font-size:14px;text-align:center;color:#000000;">
<div id="table">
<table bordercolor="#FFFFFF" cellpadding="12px" cellspacing="2px" align="center" style="margin-top:-21px;">
<colgroup>
<col style="width:50px">
<col style="width:500px">
<col style="width:150px">
<col style="width:100px">
</colgroup>
<tr>
<th style="padding-top: 5px; padding-bottom: 5px; margin-bottom:-10px; width:50px; height:35px; text-align:left; font-family:Arial; font-size:14px; color:#000000; margin-top: 50px; color: #FFFFFF; border:0px; background-color: #32CD32;">Rank</th>
<th style="padding-top: 5px; padding-bottom: 5px; margin-bottom:-10px; width:100px; height:35px; text-align:left; font-family:Arial; font-size:14px; color:#000000; margin-top: 50px; color: #FFFFFF; border:0px; background-color: #32CD32;">Name</th>
<th style="padding-top: 5px; padding-bottom: 5px; margin-bottom:-10px; width:150px; height:35px; text-align:left; font-family:Arial; font-size:14px; color:#000000; margin-top: 50px; color: #FFFFFF; border:0px; background-color: #32CD32;">Points</th>
<th style="padding-top: 5px; padding-bottom: 5px; margin-bottom:-10px; width:100px; height:35px; text-align:left; font-family:Arial; font-size:14px; color:#000000; margin-top: 50px; color: #FFFFFF; border:0px; background-color: #32CD32;">Wins</th>
</tr>
<c:forEach var="item" items="${leaderboard}" varStatus="loopStatus">
<tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}">
<td align="center" class="listtd" style="font-size:14px; border:2px; bordercolor:#000000;">
</td>
<td align="left" class="listtd" style="font-size:14px; border:2px; bordercolor:#000000; cursor:pointer;" onclick="javascript:selectPlayer('${item.id}');">
<c:out value="${item.playersLastName}"/>, <c:out value="${item.playersFirstName}"/>
</td>
<td align="center" class="listtd" style="font-size:14px; border:2px; bordercolor:#000000;">
<c:out value="${item.playersPoints}"/>
</td>
<td align="center" class="listtd" style="font-size:14px; border:2px; bordercolor:#000000;">
<c:out value="${item.playersWins}"/>
</td>
</tr>
</c:forEach>
</table>
<br/>
<br/>
<br/>
</div>
</body>
</html>