So I'd like to only apply a certain CSS if a class exists in the code elsewhere. I was wondering if this is solely possible through css or if I need to use Jquery for this. Do anyone has any thoughts on this? If I need to use Jquery, can you give an example on how that might looks like?
As you can see in my code, what I try to do is apply a margin-top when li.active exists.
Obviously my jsfiddle is not working: http://jsfiddle.net/zt40oa7d/
Or see the code below:
div.navbar {
background-color: #CCF;
}
ul.box {
margin: 0;
}
div.text {
background-color: #FFC;
padding: 10px;
}
div.page div.navbar ul.box li.active div.text {
margin-top: 100px;
}
<div class="page">
<div class="navbar">
<ul class="box">
<li class="active"><a href="#">Link 1</a>
</li>
</ul>
</div>
<div class="text">This the div that should go down due to the submenu ul</div>
</div>

div.page div.navbar ul.box li.active div.text- I don't think this is possible with pure CSS becausediv.textis neither a sibling or a descendant/child ofli.active.