Pembo Pechi
Pembo Pechi

Reputation: 59

Can I get CSS property of the child and use it on the parent?

<div class="parent">
    <div class="child"></div>
</div>

.child {
    background: red;
}

I have 5 parent divs with their child inside and each child has a different background color.

How I can get the child background color and reuse it as parent border color?

Note: Unfortunately, the child's background color is set and I cannot change it so I need some way to get it and reuse it for the parent.

Note: I am aware that with only CSS this is not possible. So, if someone can help me with JS or jQuery that would be great.

Upvotes: 0

Views: 62

Answers (0)

Related Questions