Having difficulty adjusting the appearance of the navigation bar dropdown

I'm currently facing an issue with changing the background color of my nav-bar dropdown to black, as well as adjusting the width of the dropdown options to fit the screen.

Despite trying the code provided below, I am unable to change the dropdown background from being transparent. The code did not yield any results at all.

/*-- alteration of navbar dropdown color --*/
  .navbar-default .navbar-nav .open .dropdown-menu>li>a,.navbar-default .navbar-nav .open .dropdown-menu {
    background-color: #3344ff;
    color:#ffffff;
  }

Below is the code snippet:

.navbar-inverse {
        background: #F8F9FA;
        border: none;
        color: black;
        height: 7em;
    }

    .navbar-inverse a{
        color: #7B53C1!important;
    }

    .navbar-toggle {
      border: none;
      background: transparent !important;
    }
    .navbar-toggle:hover {
      background: transparent !important;
    }
    .navbar-toggle .icon-bar {
      width: 25px;
      height: 3px;
      transition: all 0.2s;
      background: black !important;
      margin-top: 25px;
    }
    .navbar-toggle .top-bar {
      transform: rotate(45deg);
      transform-origin: 10% 10%;
    }
    .navbar-toggle .middle-bar {
      opacity: 0;
    }
    .navbar-toggle .bottom-bar {
      transform: rotate(-45deg);
      transform-origin: 10% 90%;
    }
    .navbar-toggle.collapsed .top-bar {
      transform: rotate(0);
    }
    .navbar-toggle.collapsed .middle-bar {
      opacity: 1;
    }
    .navbar-toggle.collapsed .bottom-bar {
      transform: rotate(0);
    }
    
HTML

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
    <div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" href="#collapse1" data-target="#navbar" aria-expanded="false" aria-controls="navbar">

 <span class="sr-only">Toggle navigation</span>
 <span class="icon-bar top-bar"></span>
  <span class="icon-bar middle-bar"></span>
  <span class="icon-bar bottom-bar"></span>
 </button>

        <a id='' class="header navbar-brand" href="/">
            <p id='mainTitle'>JobQuiz </p>
        </a>
        </div>

        <div id="navbar" class="collapse navbar-collapse" data-target="#collapse1">
         <ul class="nav navbar-nav">
        
        </ul>
        <ul class="nav navbar-nav navbar-right"> 
        <li class='headerBtn'> <button  id="headerBtn">Start Quiz</button></li>
        
       <% if(!currentUser){ %>
        <li class='header'> <a href="/login"> Sign In</a></li>
        <li class='header'> <a href="/register"> Sign Up </a></li>
      <% } else{ %>
        <li> <a href ="#">Signed In As: <%= currentUser.username%> </a></li>
        <li> <a href="/logout"> Log Out </a></li>
     <%  } %>

            </ul>
        </div>
    </div>
</nav>

Answer №1

The navbar dropdown in Bootstrap is specifically defined as follows:

.navbar-nav>li>.dropdown-menu

Therefore, the styling for the navbar dropdown with this class would be:

.navbar-nav>li>.dropdown-menu {
    background-color: #3344ff;
}

The anchor tags within the dropdown are defined by the following CSS rule:

.dropdown-menu>li>a

This means that the color of these anchor tags will be set to white:

.dropdown-menu>li>a {
    color: #FFF;
}

For hands-on practice and experimentation with Bootstrap themes, you can visit Bootstrap Theme, where you can use Dev Tools to modify and customize styles.

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

Javascript dynamically generates CSS animations

I need assistance creating a div with a CSS3 animated timer inside it when a button is clicked. Here is the code I have been working on: http://jsfiddle.net/arcco96/y5nov6rz/1/. Unfortunately, the div is not being created as expected. I believe the code sh ...

Utilizing the Bootstrap portfolio section, I aim to eliminate the 'ALL' tab and ensure a category is selected

Currently, I am utilizing this template If you scroll down to the WORK section, you will find the portfolio section which is filterable. The default selected option is "ALL," displaying all items. However, I would like to remove this and activate a diffe ...

I currently have a CSS menu styled with the code below. Can you recommend the most effective method for centering the entire menu in the middle of the page

I am currently using CSS for a menu on my website. What is the best way to center the entire menu on the page? How can I adjust the menu items to appear in the center instead of on the left side? ul#css3menu1{ margin:0;list-style:none;padding:0;backgro ...

Using the googleapis library within HTML is not permitted

I have been attempting to execute a simple function (uploadFile(test.txt)) within an HTML file, but I am encountering issues as my app.js and Google APIs are not being recognized or called. Node.js is throwing this error: Uncaught ReferenceError: uploadFi ...

Perpetual spinning of image grid

Are there any jQuery libraries available for continuous image rotation within an array? I have a collection of 30 partner logos that I would like to rotate continuously using either a jQuery library or plain CSS code. These images and information will be l ...

What's the best way to align divs vertically in a compact layout?

Update The reason I require this specific behavior is to ensure that all my content remains in chronological order, both on the web page and in the HTML structure. This way, even if the layout collapses into a single column on smaller screens, the content ...

A guide on showcasing Python Flask database entries in an HTML table using Jinja 2

I have a database with a table that I need to display in my web application using a specific route. My goal is to present the data from the DB in a clear and easy-to-read table format, similar to an Excel spreadsheet, through the app. Although what I hav ...

Finding the Xpath for an element that contains only a span tag, with identical attributes except for the text within

I am struggling to find the xpath for a button element that says 'Cancel'. <div class="uipresk"> <button class="something" role="button" type="button"> <span class="thisthing">OK</span> </button> ...

Guide to linking an external URL with a lightbox image

I have created a gallery and an admin gallery page. In the admin gallery, there is a delete button that appears over the image. However, when I click on it, instead of showing the message "Are you sure?", it opens a lightbox. I suspect that the code for t ...

Are you curious about the array of elements in React's carousel?

I'm currently in the process of constructing a website using React, and I have a specific challenge related to the "news" section. Within this section, I have a list of three components that represent different news items. These components are housed ...

CSS animation keyframes failing to initialize

How can I fix my CSS @keyframe animation that is not starting as expected? http://jsfiddle.net/sadmicrowave/VKzXp/ @-webkit-keyframes slideNotificationsHide { 0%{ width:70%; } 100%{ width:94%; left:0; right:0; } } #left-container{ position:abosl ...

Ensure each checkbox within a list is selected

My dilemma involves an assortment of checkboxes enclosed within LIs and SPANs in an unordered list. To simplify the checking process, I attempted using jQuery to automatically check all boxes when a button positioned above the UL is clicked. However, my ...

Bootstrap 4 has an enlarged input field when compared to the select input

I am facing an issue with the size of my select field, which appears larger than my two input fields in Bootstrap 4.3. Can anyone provide guidance on how to make the select field match the size of the input fields? Your assistance would be greatly apprecia ...

Media publications do not conform to the current trends

I'm currently utilizing the HTML-to-paper plugin to print my content on a printer. However, I've encountered an issue where it doesn't seem to apply any of the styles I've defined within @media print. The challenges I'm encounteri ...

Combining Text in HTML Using CSS to Create Layered Effects

Link to GitHub: http://github.com/user123/code I'm attempting to position "welcome" behind "home", but I've been struggling to achieve this. I've experimented with setting the position, but so far I haven't been successful. Here' ...

Tips for deactivating dropdown values based on the selection of another dropdown

There are two dropdown menus known as minimum and maximum, each containing numbers from 1 to 25. If a value is selected from the minimum dropdown (e.g. 4), the maximum dropdown should only allow values that are equal to or greater than the selected value ...

Steps for implementing scroll-based pagination in a select dropdown

HTML <select class="form-control choice requiredField" id-available name="SelectData" ng-model="box.box_id" title="Select"> <option value="" disabled selected>{{'_SELECT_BEACON_' | i18n}}</option> <option value="{{y. ...

Modifying .vue files within Laravel seems to unexpectedly impact unrelated CSS styles

I've been working on a Laravel project that involves building Vue components. Strangely, every time I update a .vue file and add it for a commit, modifications are also made to the app.css and app.js files. These changes seem to be undoing a particula ...

In which orientation does the iPad come configured as standard?

There seems to be some confusion regarding the default orientation of the iPad. While some believe it is portrait (which is how I typically use my iPad), others argue that it is actually landscape. In my CSS, I have specific settings for targeting elemen ...

Basic image slider featuring adjustable heights

I'm currently working on a basic content slider, but I've encountered an issue where the container doesn't expand as new content slides in. It seems to be related to the absolute positioning of the content items. If I don't use absolute ...