N
N
Nikita2020-02-17 00:36:27
css
Nikita, 2020-02-17 00:36:27

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

4 answer(s)
D
Denis Gribanov, 2019-06-14
@gribanov2la

https://getbootstrap.com/docs/4.3/getting-started/...

M
Max, 2020-02-17
@SonyFan23

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'

A
Alex, 2020-02-17
@Kozack

Not a very clear question. But I guess https://developer.mozilla.org/ru/docs/Web/CSS/Usin...

R
Roman Chuvilev, 2020-02-17
@FrontEndTarot

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 question

Ask a Question

731 491 924 answers to any question