Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to use :not pseudo selector containing adjacent sibling combinator?

What I am trying to achieve – when table footer is rendered, I want to remove the border radius from the table cells within the last tr inside table body. Not sure if the following code should even work:

table tbody:not(+ tfoot) tr td {
  border-radius: 0;
}
table {
  border-collapse: separate;
  border-spacing: 0;
}

td {
  border: 1px solid;
  border-radius: 4px;
  background-color: red;
}

table tbody:not(+ tfoot) tr td {
  border-radius: 0;
}
<table class=with-footer>
  <tbody>
    <tr><td>Body cell</td></tr>
    <tr><td>Body cell</td></tr>
  </tbody>
  <tfoot>
    <tr><td>Footer cell</td></tr>
  </tfoot>
</table>

I am open to other suggestions too, maybe I am overcomplicating the task.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can be more compatible (including with current Firefox) with :last-child:

table {
  border-collapse: separate;
  border-spacing: 0;
}

td {
  border: 1px solid;
  border-radius: 4px;
  background-color: red;
}

table > tbody:not(:last-child) > tr:last-child > td {
  border-radius: 0;
}
<table class=with-footer>
  <tbody>
    <tr><td>Body cell</td></tr>
    <tr><td>Body cell</td></tr>
  </tbody>
  <tfoot>
    <tr><td>Footer cell</td></tr>
  </tfoot>
</table>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading