Answer the question
In order to leave comments, you need to log in
How can I make the header take the color from the nearest component?
I 'm developing an application, I ran into such a problem that the header always has a certain color.
Tell me how to make the header take the color from the nearest element?
Answer the question
In order to leave comments, you need to log in
If you want the color of the parent, then
you can't use the color of the child. Can't use neighbor color after header
color: 'inherit'
Not a very clear question. But I guess https://developer.mozilla.org/ru/docs/Web/CSS/Usin...
document.querySelector("header").backgroundColor =
window.getComputedStyle(document.body.querySelector(".colorful-component")).backgroundColor;
Slow but versatile.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question