Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

visiblity:hidden of table-cell hides background-color of parent table-row

I have some forms that are structured using display:table-row and display: table-cell. On Firefox 52, I could hide a cell element using visibility:hidden, hiding the cell but keeping the structure defined by CSS (instead of using display:none).

On Firefox 64 though (and also chrome), when I hide the visibility of the cell, the parent table-row loses its background color on that position.

Here's a snippet showing the issue:

#tableRow{
  display: table-row;
  background-color: #f5f5f5;
}
.cell{
  display:table-cell;
}
#hide{
  visibility:hidden;
}
<div id="tableRow">
  <a href="#" class="cell">Visible</a>
  <a href"#" class="cell"id="hide">Not visible</a>
  <a href="#" class="cell">Visible</a>
</div>

I tried using opacity: 0 but some elements are clickable or have different events and opacity on 0 won't help.

Any thoughts? Is this intended?

like image 591
Sebastianb Avatar asked Dec 24 '18 13:12

Sebastianb


People also ask

How do I change the background color of a row in a table?

The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. It is not supported by HTML 5. Attribute Values: color_name: It sets the background color by using the color name.

How do I change the background color of a cell in a table?

Add or change a fill color Select the cells in which you want to add or change the fill color. On the Tables tab, under Table Styles, click the arrow next to Fill. On the Fill menu, click the color you want.

Which tag sets the background color to the table?

The HTML <table> bgcolor Attribute is use to specify the background color of a table. Attribute Values: color_name: It sets the text color by using the color name.

Can we use background color property for giving background color in the table?

In HTML, table background color is specified using Cascading Style Sheets (CSS). In particular, you use the CSS background-color property to set the background color for your table. You can also specify a separate background color for your table rows and table cells if you like.


1 Answers

I would consider box-shadow to simulate a background coloration and avoid this bug *

.container {
  display: table;
}

#tableRow {
  display: table-row;
  box-shadow: -100vw 0 0 red inset;
}

.cell {
  display: table-cell;
  padding: 10px;
}

#hide {
  visibility: hidden;
}
<div class="container">
  <div id="tableRow">
    <a href="#" class="cell">Visible</a>
    <a href="#" class="cell" id="hide">Not visible</a>
    <a href="#" class="cell">Visible</a>
  </div>
</div>

*it's probably not a bug but I am not able to find any specification describing this behavior

like image 132
Temani Afif Avatar answered Sep 29 '22 07:09

Temani Afif