动态创建Table每行随机换色
<div id="cnblogs_post_body"> 最近在学习javascript,所以写下例子,练习一下,记录今天,方便以后查看!JavaScript用的是静态私有变量,每个实例都没有自己的私有变量。
Css代码如下:
<div class="cnblogs_code"> 1 table {max-width: 100%;background-color: transparent;border-collapse: collapse;border-spacing: 0;} 2 .table {width: 100%;margin-bottom: 20px;} 3 .table th,.table td {padding: 8px;line-height: 20px;text-align: left;vertical-align: top;border-top: 1px solid #dddddd;} 4 .table th {font-weight: bold;} 5 .table thead th {vertical-align: bottom;} 6 .table tbody + tbody {border-top: 2px solid #dddddd;} 7 .table-hover tbody tr:hover td,.table-hover tbody tr:hover th {background-color: #f5f5f5;} 8 .table tbody tr.success td {background-color: #dff0d8;} 9 .table tbody tr.error td {background-color: #f2dede;}10 .table tbody tr.warning td {background-color: #fcf8e3;}11 .table tbody tr.info td {background-color: #d9edf7;}12 .table-hover tbody tr.success:hover td {background-color: #d0e9c6;}13 .table-hover tbody tr.error:hover td {background-color: #ebcccc;}14 .table-hover tbody tr.warning:hover td {background-color: #faf2cc;}15 .table-hover tbody tr.info:hover td {background-color: #c4e3f3;}
页:
[1]