0

I can't get the background colour of my dropdown to change when it's open.

My CSS code is

.dropdown.open { background-color: black; } 

My HTML is

<ul class="nav navbar-nav navbar-right"> <li><a href="#web-hidden" onClick="TypeWeb()">WEB DEVELOPMENT</a></li> <li><a href="#programming-hidden" onClick="TypeProgramming()">PROGRAMMING</a></li> <li><a href="#design-hidden" onClick="TypeDesign()">DESIGN</a></li> <li><a href="#game-hidden" ></a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" onClick="TypeGameDesign()"> GAME DEVELOPMENT <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="#">Unity3D</a></li> <li role="separator" class="divider"></li> <li class="dropdown-header">Coming...</li> <li><a href="#">UE4</a></li> <li><a href="#">VR</a></li> </ul> </li> </ul> 
2
  • Where is the function to open and close the li dropdown element? Shouldn't it have an onclick callback: <li class="dropdown" onclick="toggleState();"> Commented Dec 1, 2016 at 20:39
  • can't this be done with css? Commented Dec 1, 2016 at 20:44

1 Answer 1

3

The background color belongs to the a. So, use this:

.dropdown.open > a { background-color: #000 !important; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.