Check this fiddle
I have a dropdown
and when the dropdown
is toggled, I want to change another div's
background-color (div's
with classes .main-content
and .reqdiv
is this case).
I have tried these selectors ~
, >
, +
and I know these won't work in my case. Can anyone please suggest me how to solve this without using JS/JQuery.
.main-content {
height: 200px;
width: 100%;
background: green;
}
.dropdown-menu {
top: 35px!important;
}
.nav-btn.show~.main-content {
background: blue;
}
.nav-btn.show>.main-content {
background: blue;
}
.nav-btn.show+.main-content {
background: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="nav-btn">
<button class="btn dropdown-toggle " type="button" data-toggle="dropdown"><b>Language</b>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#">HTML</a>
</li>
<li><a href="#">CSS</a>
</li>
<li><a href="#">JavaScript</a>
</li>
</ul>
</div>
</div>
<div class="#reqdiv">
//text
</div>
<div class="main-content">
</div>