I want to add a ::before selector to some cells of the table, which has position:absolute , but it does not work:
table{ border:1px solid #ccc; padding:10px; } table td{ border:1px solid #ccc; padding:5px; } .useBefore::before{ content:'before'; position:absolute; }
<table> <tbody> <tr> <td>bird</td> <td>animal</td> <td>nature</td> </tr> <tr class='useBefore'> <td>building</td> <td>robot</td> <td>city</td> </tr> </tbody> </table>
I noticed that if I add ::before to all tr , then it will work:
table{ border:1px solid #ccc; padding:10px; } table td{ border:1px solid #ccc; padding:5px; } tr::before{ content:'before'; position:absolute; }
<table> <tbody> <tr> <td>bird</td> <td>animal</td> <td>nature</td> </tr> <tr class='useBefore'> <td>building</td> <td>robot</td> <td>city</td> </tr> </tbody> </table>
But this is not what I want, because I want to add it only to some of them.
Adam
source share