Possible to change opacity on child elements based on parent sibling selector?
<header>
<div class="menu">
<div class="overlay"></div>
<div class="blur"></div>
</div>
<div class="mobile-menu"></div>
</header>
How would I go about changing the opacity of overlay and blur, only when <div class="mobile-menu"></div> becomes <div class="mobile-menu menu-open"></div>?
Or is it just better to use JavaScript for this?
2 Replies
:has(> .mobile-menu.menu-open)
https://developer.mozilla.org/en-US/docs/Web/CSS/:has
just use that in cssif you don't want to use
:has()
yet and if you are able to swap .menu
and .mobile-menu
in the html