Quantcast
Channel: Active questions tagged flexbox - Stack Overflow
Viewing all articles
Browse latest Browse all 1307

Any way to set parent background-color on the basis of child class using css?

$
0
0

is there any way to set parent background-color on the basis of child class using css?

here is my codehttps://jsbin.com/bahodalila/edit?html,css,js,outputif child have red class parent should set background-color red.If child have yellow class parent should set background-color yellow.

<div class="par"><div class="red">      helli</div></div>.par{  background-color:red;}.par{  background-color:yellow;}.par{  width:200px;  height:200px;  border:1px solid blue;}.red{  width:100px;  height:100px;  color:red;  border:1px solid;  background-color:green}

will I use javascript in this case ? is there any way to using css ?


Viewing all articles
Browse latest Browse all 1307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>