Reputation: 2991
Can I inherit first non-transparent background-color for the element with only css rule? For example if I need some element to be non-transparent inside some other element with background-color but it's nested into some other transparent elements.
Upvotes: 7
Views: 1069
Reputation: 943579
No.
The only element you can inherit a value from is the immediate parent.
The closest you could come would be to use JavaScript to search the DOM for an element with a computed value for that property which isn't transparent and then apply it to the current element.
You'd probably be better off with CSS rulesets that use descendant combinators such as:
.example,
.example .solid {
background: red;
}
Upvotes: 4