Inside following example, I have table cells which have the CSS property opacity
set to a value of 0.5
.
It seems like when I do not replace this property with certain specific CSS properties, it will cause problems:
table,
th,
td {
border: 1px solid #000;
}
th {
background-color: #ccc;
position: sticky;
top: 0;
}
td {
/* Works: */
/*background-color: rgba(204, 204, 204, 0.5);
color: rgba(0, 0, 0, 0.5);
border-color: rgba(0, 0, 0, 0.5);*/
/* Does nto work? */
background-color: #ccc;
opacity: 0.5;
}
<table>
<thead>
<tr>
<th>
Tuturu
</th>
<th>
asdasdasd
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
asdasdas
</td>
<td>
asdasdsa
</td>
</tr>
<tr>
<td>
asdasdas
</td>
<td>
asdasdsa
</td>
</tr>
<tr>
<td>
asdasdas
</td>
<td>
asdasdsa
</td>
</tr>
</tbody>
</table>
<div style="height: 200px;">
</div>
If you start scrolling, the effect will be visible. The effect is pretty awesome, kind of ghost-ish like. (is that even a word?)
Still this is something not desirable.
As one might see, the table head looks transparent as well now.
I have been reading on MDN that:
Opacity is the degree to which content behind an element is hidden, and is the opposite of transparency.
Am I required to use rgba()
here instead of opacity? Or something else to solve the appearance of this example table?