How to Customize the Text Color of Dropdown Toggle in Bootstrap 4 When the Dropdown is Activated

I'm fairly new to working with Bootstrap and I am attempting to adjust the color of the opened dropdown-toggle. In the image below, you can see that the text for "Services" in the dropdown-toggle remains white when clicked and opened, but I would like it to be beige instead. I have tried various css pseudo-classes such as active, focus, etc. but none seem to work.

https://i.sstatic.net/p6D8a.jpg

Here is the code:

<!--Collapsing sidebar-->
<div class="collapse" id="sidebar">
    <div class="navbar-nav ml-auto">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="index.html">About Us <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item my-2">
                <a class="nav-link" href="index.html">Portfolio<span class="sr-only"></span></a>
            </li>
            <li class="nav-item my-2 dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="utilitiesDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Services
                </a>
                <div class="dropdown-menu" id="dropdown-menu-sidebar" aria-labelledby="utilitiesDropdown">
                    <h6 class="dropdown-item my-1" href="#">Link 1</h6>
                    <div class="dropdown-divider"></div>
                </div>
            </li>
            <li class="nav-item my-2 dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="utilitiesDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Pricing
                </a>
                <div class="dropdown-menu" aria-labelledby="utilitiesDropdown">
                    <h6 class="dropdown-item" href="#">Content &amp; Components</h6>
                    <div class="dropdown-divider"></div>
                </div>
            </li>
            <li class="nav-item my-2"><a class="nav-link" href="index.html">Order Now<span class="sr-only"></span></a></li>
            <li class="nav-item my-2"><a class="nav-link" href="index.html">Contact<span class="sr-only"></span></a></li>
        </ul>
    </div>
</div>

Any suggestions on how to change the text color of the dropdown-toggle when the dropdown is open? Thank you!

Answer №1

If you feel like updating the nav-link, go ahead and modify the text to your liking... Take this as an instance

<a class="nav-link text-primary..."

Alternatively, you could incorporate a custom style

.nav-link{
 color:#000 -- Input the desired color here
}

Answer №2

apply the following css style

.menu-items .displayed a {
     color: purple !important; /* desired text color */
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Preventing link color changes in HTML generated by Python

I am currently developing an HTML page using Python. The issue I am facing is that when the page is created with links, clicking on a link permanently changes its color. Disabling this behavior in HTML has not been successful when creating the page with Py ...

Is it possible to create a blurred effect on an image while preserving the clarity of text within

I have been attempting to create an effect where the image blurs and then reveals text. However, I have encountered issues where the image either blurs completely or behaves strangely. My code is behaving oddly, almost like it's giving a signal. (I&a ...

Variation in pixel dimensions

What causes the difference between Chrome and screen capture? I am utilizing bootstrap. I desire to achieve true pixels of 50px. HTML <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-h ...

Guide on deactivating the HTML drawer layout on a website with Selenium using Java

I am currently working on automating a website and I have encountered a challenge with a drawer Menu Panel. My goal is to open the menu, verify certain elements within it, and then close or hide it. However, I am facing difficulty in closing/hiding this d ...

What steps are involved in creating a circular shape on canvas?

I am trying to create a circular shape in the canvas using the code below. The code involves moving an object with keyboard keys, and I need help making the canvas shape into a circle without affecting the functionality of the code. I attempted to modify t ...

Vertical text on rigid bars

Hey there, I've encountered an intriguing problem that's got me stumped. I'm attempting to create a menu made up of vertical bars that span the full height of the window and have a fixed position. I want the text within these bars to displa ...

How can I retrieve the values of checkboxes from PHP and MySQL?

I created a table that displays pizza names, types, and prices using a loop to populate the table dynamically. <form action="Cart.php" method="post"> <table border="1" cellpadding="10"> <tr> <th>Pizza name</th> <th>Pizz ...

The hyperlink for making phone calls appears twice on an Android phone

When you click on the number, it will be displayed twice in the phone screen like this... 12345678910,12345678910 ...instead of just once... 12345678910 Take a look at the code snippet below: {#if order.salesRep} <div class="info"> ...

Issue with the alignment of two rows in an HTML template

I'm encountering an issue with the spacing between two rows/elements in an HTML template. I'm working on creating a product grid for our restaurant and used a template sourced from the Internet. As shown in this picture: issue1 The problem lies ...

Dynamically add a Font Awesome icon to the background of an input text field with React and react-fa

Utilizing ReactJs and react-fa to access Font Awesome icons, I am attempting to dynamically place one of the icons inside a text input. The following is my code snippet: import React, { Component } from 'react'; import PropTypes from &a ...

Centering the overlay gallery box in MonoBook Skin of MediaWiki using CSS

While working on transforming the MonoBook Skin into a DarkMode version, I encountered an issue with the gallery overlay css. The Overlay displays a semi-translucent white box with text at the bottom by default, overlaying the image. I made adjustments to ...

What is the best way to assign the "active" class to a navigation list item using JavaScript within Bootstrap 4?

Update: just to clarify, I'm working on activating the navbar button based on the current page. I have a navigation bar set up and I am trying to dynamically add an "active" class to the li element when you are on that specific page. However, for som ...

The reason the CSS direct descendant selector does not affect Angular components

We are working with a basic main.html. <app> <sidebar></sidebar> <main-content> <router-outlet></router-outlet> </main-content> </app> After loading a component through routing (changing the ...

How to eliminate the space between text and list-style-image in CSS

My ul list items have an image added using the list-style-image property. Here is an example of what I have done: JSFiddle ul { list-style-image: url('http://placehold.it/50x40'); } <ul> <li>Coffee</li&g ...

Disable the parent CSS styling when focusing on the child button

Within an anchor tag, I have a div element. The CSS on the :active state is set to transform the element, but I want to avoid this behavior when focusing on the child element bx--overflow-menu. I am working with NextJS using styled-jsx and SaSS. Here is my ...

Conceal content in Bootstrap navbar when clicking on #link

I am facing an issue with the navbar-fixed-top element as it is causing content to be hidden from the container. To resolve this common problem, you can add the following CSS code: body { padding-top: 70px; } After applying the above code, the container ...

Free Image Gallery software solution

Looking for a recommendation on an open-source image gallery for our website. Planning to use PHP, Python, or Ruby with a MySQL backend if needed. It's for a Sailing Club, so I need something where certain members can create folders for each day out a ...

Trifecta Card Arrangement

<div class="ibm-columns" data-items=".ibm-card" style="padding-bottom: 96px;" data-widget="setsameheight"> <div class="uc1 ibm-col-12-4 card" style="display: none;"> <div class="ibm-card mobileFlex ...

Encountering a CSS problem while attempting to design a section featuring a background image

On this page, I have the login bar on the right and the footer at the bottom. I want a div to sit in the area currently occupied by the background image and fill it with the full background image. Currently, everything is wrapped in a wrapper and the back ...

Tips on including a trash can symbol to rows in a bootstrap table using React

I am working on a table that contains various fields, and I want to add a trash icon to each row so that when it is clicked, the specific row is deleted. However, I am encountering an issue where the trash icon is not showing up on the row and I am unable ...