Brooklyn Nicholson
Brooklyn Nicholson

Reputation: 646

Expanding TR regardless of its TH in a table

I have a dataset that has an optional last TD that is required to have a TH but regardless of that, I need the TRs to expand to show the background-color (fill it in).

Here's a fiddle showing my issue: http://jsfiddle.net/xkwCp/1/

I need the last three rows (the second tbody) to expand (organically or by JS). But it needs to read that there is no 3rd TD, and expand it as needed regardless of that TD, and without adding dummy TDs because it'll be generated dynamically.

Upvotes: 1

Views: 98

Answers (2)

Galled
Galled

Reputation: 4206

I have an answer in jQuery, not CSS:

If you need only for a scenario where the last tbody is incomplete, you can use this

If you need something more generic, with tbodies (complete or incomplete) piled with any order you can use this

Upvotes: 2

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

You need to count the empty rows, then use rowspan on the last column. You cannot do this with CSS.

Upvotes: 1

Related Questions