background-color属于css样式表里面的所以这样写style="background-color:背景颜色"
bgColor属于HTML里面的所以这样写bgColor="背景颜色"
我的理解:
建议统一用样式的写法,在实现表格隔行变色的时候,在IE里把background-color改为bgcolor,就没效果
代码如下:
<style>
.tbDatalist tr{
background-color:expression(this.background-color=((this.rowIndex)%2==0)?'#a5e5aa':'#d9ffdc');
/* 以下写法在IE里可以,而且background-color不能改为bgcolor,但是在firefox里无效果
background-color:expression((this.sectionRowIndex%2==0)?"#a5e5aa":"#d9ffdc")}
*/
}
</style>
<table class="tbDatalist" summary="list of members in EE Studay" id="oTable">
<tr>
<th scope="col">姓名</th>
<th scope="col">班级</th>
<th scope="col">出生日期</th>
<th scope="col">星座</th>
<th scope="col">电话</th>
</tr>
<tr>
<td>slepox</td>
<td> W19</td>
<td>Nov 18th</td>
<td>Scorpio</td>
<td>0658635</td>
</tr>
<tr>
<td>smartlau</td>
<td>W19</td>
<td>Dec 30th</td>
<td>Capricorn</td>
<td>0006621</td>
</tr>
</table>
CSS与HTML背景色应用
本文探讨了在CSS和HTML中使用背景颜色的不同方法,并通过示例代码展示了如何实现表格行的交替颜色显示。讨论了在不同浏览器下,如IE与Firefox中使用background-color属性与bgcolor属性的效果差异。
3556

被折叠的 条评论
为什么被折叠?



