If you're looking to achieve this effect with CSS, you can use a combination of the nth-last-child
selector and rowspan. However, keep in mind that it may appear a bit complex and cumbersome if you want it to work for all scenarios.
The basic algorithm involves targeting elements using the following code:
tr:nth-last-child(x) th[rowspan >= x]
Pure CSS doesn't provide a direct way to accomplish this task, so you'll need to break it down into smaller steps.
To start, you can select all th elements in the last row by using the following CSS rule:
tr:last-child th { /*your CSS*/ }
After that, things get more intricate. Any th element will touch the bottom border if its rowspan spans the remaining rows between its own row and the bottom border. For example, a th element in the 2nd-last tr requires a rowspan of 2 to reach the bottom. You'll have to specify this for each row individually like so:
tr:nth-last-child(2) th[rowspan='2'],
tr:nth-last-child(3) th[rowspan='3'],
tr:nth-last-child(4) th[rowspan='4'] { /*Your CSS */ }
While this solution may not be elegant, it does get the job done. Just make sure to account for all possible row variations if you want to stick to pure CSS.
There might be better ways to streamline this process using tools like SASS or LESS (or even JQuery), but as far as I know, there isn't a straightforward CSS-only method. If you have any suggestions for improving this approach, please share!
UPDATE: Check out this modified JSFiddle Here to see a practical demonstration of the concept.