Highlighting the clicked row of a striped HTML table

后端 未结 5 1794
夕颜
夕颜 2020-12-12 21:54

Here\'s an example of my problem on jsFiddle.

I have a table with striped rows imposed by using tr:nth-child(odd) in the CSS, as is done in Twitter Boot

5条回答
  •  忘掉有多难
    2020-12-12 22:53

    Just edit the Bootstrap .table-striped CSS class to this:

    .table-striped tbody tr:nth-child(odd),
    .table-striped tbody tr:nth-child(odd) th {
        background-color: #f9f9f9;
    }
    
    .table-striped tbody tr:nth-child(even){
        background-color: yellow;
    }
    

    Remove all the td styling you do not want. Then it works.

    When you click the row this style should also be applied:

    .selected { background-color:#2f96b4 !important; }
    

    It will not work without the !important.

提交回复
热议问题