Problems with sticky columns and row with background-color with alpha channel
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Applying a background-color with transparency on a row should apply that color on it without problems, even when used together with sticky columns.
What is the current behavior?
The non-sticky content will become visible when a background-color with transparency is applied on the row. This will also make the sticky column to have a darker color, because they will mix their level background-color with the very same background color of the non-sticky part of the row.
What are the steps to reproduce?
- Go to the sticky columns example in docs
- Add
background-color: rgba(0, 0, 255, 0.5);on the firsttrof thetbody - Notice different colors on sticky and non-sticky columns
- Scroll horizontally to see that non-sticky columns are visible under the sticky ones
What is the use-case or motivation for changing an existing behavior?
I'm trying to apply a :hover effect to the rows in a table with sticky columns.
I'm managing colors with mat-* functions and manually converting the color to a RGB will make that line of code not maintenable in case of color changes.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 6.0.9 Material 6.3.3
Hi, I see your issue. You can fix this by applying 3 css classes to your css.
`/** Apply default row with background color with alpha. All the child tds will have this, regardless if it is sticky or not. */ tr.mat-row{ background-color: rgba(0, 0, 255,.5); }
/** Add specificity for only the sticky columns background to be the same color but set alpha to 1, it has higher specificity and makes the background the color but overrides the blending. This targets or resets the sticky columns alpha back to 1 so no bleed through on horizontal scrolling. **/ tr.mat-row > td.mat-table-sticky { background: rgba(0,0,255,1); }
/** Highlights all sticky rows cells only, in this case, a test color like yellow, alpha should be 1 so there should be no transparency **/ tr.mat-row:hover > td.mat-table-sticky { background: yellow; } ` I assume the last css rule is what you want on hover. The non-sticky cells won't have a hover effect. Is this what you are expecting? Let me know if this works for you.
Mmm... No, not really, sorry. I'll try to explain it better: if you followed the instructions I gave, you should have noticed that sticky columns have a different color than the non-sticky ones. Like this, to be clear:

I expected the sticky columns to have the same color of other columns, like this

This is obviously related to the background-color transparency and how sticky positioning works (and a chain of background: inherit which I guess serves some purpose)
I guess so, I see your issue and been looking at this. The only way to get this to work is to set your alpha to 1 for the time being. If you want that exact color, you should make your hover color rgba color to match this light color to give it this lighter blue you want.
I tried look at the sticky z-index, which is 1 but changing the sticky z-index doesn't help since a transparent background is going to show underneath, especially as you horizontally. Background inherit means you inherit the default background property from a parent element.
Well, if I come up with some solution I'll update this issue I guess. For now I'll stick to RGB colour
Closing as this is working as expected. Because the row holds in place and the other context is a lower z-index in the stacking context, with the alpha channel defined the colors from below will be partially visible.
This is not specific to Angular Material, but is actually a characteristic of sticky headers in web browsers in general.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.