Changing the background color in the drop-down menu
source link: https://www.codesd.com/item/changing-the-background-color-in-the-drop-down-menu.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Changing the background color in the drop-down menu
I'm currently in the process of making a navigation bar for a website using bootstrap. Everything seems to be working as expected. However on the menu I have a li
which then displays a dropdown. This is where the problem comes in. When I click on the li
the background seems to change to black and I can't figure out where that's coming from.
My markup looks as follows:
<div class="navbar navbar-inverse navbar-fixed-top" runat="server">
<div class="container">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav" runat="server">
<li>
<a href="#">1</a>
</li>
<li>
<a href="#">2</a>
</li>
<li>
<a href="#">3</a>
</li>
<li>
<a href="#">4</a>
</li>
<li>
<a href="#">5</a>
</li>
<li class="dropdown"><a runat="server" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">Training Group<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="#">1</a>
</li>
<li>
<a href="#">2</a>
</li>
<li>
<a href="#">3</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
I want so when I the back ground stays white. I've tried
.navbar> li.dropdown.active.open > a { background-color: #fff; }
But it doesn't seem to change the background colour. Can someone shed some light on where I'm going wrong please.
Thanks in advance for your help and support
The first comment (by Tamil Selvan) may work for you (assuming the rule is specific enough), but it'd probably help if you knew why your original code fails: the reason is that >
after .navbar
. That >
is a direct-child selector and the li
s are not direct children of .navbar
.
UPDATE: author posted a Pen and it became more clear he wasn't targeting the dropdown-menu at all, it was about the triggering element, so here's what helped:
Looks like the CSS responsible for the black background color on the LI that you click to reveal the dropdown is:
.navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:focus, .navbar-inverse .navbar-nav>.open>a:hover.navbar-inverse
Recommend
-
46
In SwiftUI the background color can be applied to every view. To change the background color to the whole screen a ZStack must be used. In this tutorial a red background color is set using a ZStack .SwiftUI requires Xcod...
-
12
Sometimes, we need to use a different color on the Application Status Bar on both devices i.e. Android and IOS. In this article, we are going to learn how to change status bar background color in your
-
7
Setting the background color when generating images from Canvas.toDataURL Monday, January 31, 2011 One of the cool features of the HTML5 canvas element is the toDa...
-
6
Preamble¶ from plotapi import Sankey Sankey.set_lic...
-
7
Color code in the menu barColor Peeker is a realtime digital color meter that sits quietly in your menu bar. It shows the hex code of the color under your mouse pointer.You can also turn on Copy on Right Click, so that when...
-
4
SVG Overlay and Infinite Menu Background Animation A little menu effect with an SVG overlay and an infinite background CSS animation. ...
-
6
How can I change the opacity of the background image without changing the div content? advertisements This question a...
-
5
Javascript Drop Down Menu Updated: February 02, 2017 This post gives an example of...
-
12
How to Stop Others From Changing Your Windows Desktop Background By Modisha Tladi Published 11 hours ago Do y...
-
6
How to Create Drop-Down Menu in AndroidHow to Create Drop-Down Menu in Android80 Views14/07/2022<p>In this video, we will see how to...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK