Skip to content

Commit 1b20446

Browse files
authored
fix(table): invented a helper class to solve the styling logic when rowspan is used in tables
The styling is sometimes broken in the table element, when rowspan used. This confused later table rows which then usually have less columns. As there is no way to look backward via CSS to find out if a previous column in a row was rowspanned and the table component is not a JS module, i invented a little helper class to solve this issue via pure html/css. One just has to create a td node , where it is usually not necessary, and give it the new rowspanned class. This will just hide it from the screen but all existing table classes are working again, because the amount of td remains the same just like if there was no rowspan used at all.
1 parent 4deee38 commit 1b20446

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/definitions/collections/table.less

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
transition: @transition;
6060
}
6161

62+
/* Rowspan helper class */
63+
.ui.table th.rowspanned,
64+
.ui.table td.rowspanned {
65+
display:none;
66+
}
67+
6268
/* Headers */
6369
.ui.table > thead {
6470
box-shadow: @headerBoxShadow;
@@ -180,13 +186,13 @@
180186
.ui.table:not(.unstackable) > tbody,
181187
.ui.table:not(.unstackable) > tr,
182188
.ui.table:not(.unstackable) > tbody > tr,
183-
.ui.table:not(.unstackable) > tr > th,
184-
.ui.table:not(.unstackable) > thead > tr > th,
185-
.ui.table:not(.unstackable) > tbody > tr > th,
186-
.ui.table:not(.unstackable) > tfoot > tr > th,
187-
.ui.table:not(.unstackable) > tr > td,
188-
.ui.table:not(.unstackable) > tbody > tr > td,
189-
.ui.table:not(.unstackable) > tfoot > tr > td {
189+
.ui.table:not(.unstackable) > tr > th:not(.rowspanned),
190+
.ui.table:not(.unstackable) > thead > tr > th:not(.rowspanned),
191+
.ui.table:not(.unstackable) > tbody > tr > th:not(.rowspanned),
192+
.ui.table:not(.unstackable) > tfoot > tr > th:not(.rowspanned),
193+
.ui.table:not(.unstackable) > tr > td:not(.rowspanned),
194+
.ui.table:not(.unstackable) > tbody > tr > td:not(.rowspanned),
195+
.ui.table:not(.unstackable) > tfoot > tr > td:not(.rowspanned) {
190196
display: block !important;
191197
width: auto !important;
192198
}
@@ -469,13 +475,13 @@
469475
.ui[class*="tablet stackable"].table > tbody,
470476
.ui[class*="tablet stackable"].table > tbody > tr,
471477
.ui[class*="tablet stackable"].table > tr,
472-
.ui[class*="tablet stackable"].table > thead > tr > th,
473-
.ui[class*="tablet stackable"].table > tbody > tr > th,
474-
.ui[class*="tablet stackable"].table > tfoot > tr > th,
475-
.ui[class*="tablet stackable"].table > tr > th,
476-
.ui[class*="tablet stackable"].table > tbody > tr > td,
477-
.ui[class*="tablet stackable"].table > tfoot > tr > td,
478-
.ui[class*="tablet stackable"].table > tr > td {
478+
.ui[class*="tablet stackable"].table > thead > tr > th:not(.rowspanned),
479+
.ui[class*="tablet stackable"].table > tbody > tr > th:not(.rowspanned),
480+
.ui[class*="tablet stackable"].table > tfoot > tr > th:not(.rowspanned),
481+
.ui[class*="tablet stackable"].table > tr > th:not(.rowspanned),
482+
.ui[class*="tablet stackable"].table > tbody > tr > td:not(.rowspanned),
483+
.ui[class*="tablet stackable"].table > tfoot > tr > td:not(.rowspanned),
484+
.ui[class*="tablet stackable"].table > tr > td:not(.rowspanned) {
479485
display: block !important;
480486
width: 100% !important;
481487
}

0 commit comments

Comments
 (0)