javascript - Bootstrap rule and my class doesn't cooperate -
on page, use bootstrap. created table , has 3 classes, check it:
<!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <!-- optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"> <!-- latest compiled , minified javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <table class="table table-striped table-bordered"> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> now use code jquery. code added class highlight. class highlight:
.highlight { background-color: orange; } <!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <!-- optional theme --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"> <!-- latest compiled , minified javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <table class="table table-striped table-bordered"> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> when table has 1 class: "table" it's working. must have table-striped , table-bordered. when is, highlight working numbers. how can fix that?
it's css specificity issue.
bootstrap applies alternating row class this:
.table-striped>tbody>tr:nth-of-type(odd) you need specific or more.
row highlight example:
.table>tbody>tr.highlight>td { // change background color here } cell highlight example:
.table>tbody>tr>td.highlight { // change background color here } note: i'm assuming want highlight rows or cells, not entire table.
Comments
Post a Comment