Struggling with replicating the btn-dark style in this multi-level Bootstrap 4 dropdown clone

I'm having trouble getting this multi-level Bootstrap 4 clone dropdown menu to match the appearance of a Bootstrap 4 btn-dark. The colors and styling are all off, and I'm not sure which elements to adjust to achieve the desired look. Any guidance would be much appreciated :).

/* custom styles for multi-level bootstrap dropdown menu */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu>.dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -6px;
    margin-left: -1px;
    border-radius: 0 6px 6px 6px;
}

.dropdown-submenu:hover>.dropdown-menu {
    display: block;
}

.dropdown-submenu>a:after {
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover>li{
background-color: aqua;
}

.dropdown-submenu:hover>a:after {
    border-left-color: #fff;
}

.dropdown-submenu.pull-left {
    float: none;
}

.dropdown-submenu.pull-left>.dropdown-menu {
    left: -100%;
    margin-left: 10px;
    border-radius: 6px 0 6px 6px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>



<div class="dropdown">
            <button class="btn btn-secondary dropdown-toggle btn-dark" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Dropdown
            </button>
            <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
                <li class="dropdown-item"><a href="#">Some action</a></li>
                <li class="dropdown-item"><a href="#">Some other action</a></li>
                <li class="dropdown-divider"></li>
                <li class="dropdown-submenu">
                  <a  class="dropdown-item" tabindex="-1" href="#">Hover me for more options</a>
                  <ul class="dropdown-menu">
                    <li class="dropdown-item"><a tabindex="-1" href="#">Second level</a></li>
                    <li class="dropdown-submenu">
                      <a class="dropdown-item" href="#">Even More..</a>
                      <ul class="dropdown-menu">
                          <li class="dropdown-item"><a href="#">3rd level</a></li>
                            <li class="dropdown-submenu"><a class="dropdown-item" href="#">another level</a>
                            <ul class="dropdown-menu">
                                <li class="dropdown-item"><a href="#">4th level</a></li>
                                <li class="dropdown-item"><a href="#">4th level</a></li>
                                <li class="dropdown-item"><a href="#">4th level</a></li>
                            </ul>
                          </li>
                            <li class="dropdown-item"><a href="#">3rd level</a></li>
                      </ul>
                    </li>
                    <li class="dropdown-item"><a href="#">Second level</a></li>
                    <li class="dropdown-item"><a href="#">Second level</a></li>
                  </ul>
                </li>
              </ul>
        </div>

Answer №1

Update Completed

To modify the background color, create a CSS declaration with the selector "ul.dropdown-menu.multi-level.show" and set the color to #343a40 in the provided code snippet.

A quick tip for future reference: You can use Chrome's F12 key to open the inspector tool. Inspect the element you wish to change to determine its current styling properties.

Then, utilize "ul.dropdown-menu" to handle the secondary levels of the dropdown menu.

ul.dropdown-menu.multi-level.show a:link{
color:white;
}
li.dropdown-item:focus, li.dropdown-item:hover {
background-color:#1d2124;
}
a.dropdown-item:hover {
background-color:#1d2124;
}
ul.dropdown-menu.multi-level.show {
background-color:#343a40;
}    
ul.dropdown-menu {
background-color:#343a40;
}

/* begin multi-level bootstrap style dropdown menu */
.dropdown-submenu {
    position: relative;
}
ul.dropdown-menu.multi-level.show a:link {
    color: white;
}
... (additional CSS styles)
...
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
... (HTML markup)
...

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

What steps can be taken to resolve the vulnerability in webpack-pwa-manifest?

Looking for solutions to address the [email protected] and minimist vulnerability. I attempted removing node/modules and package-lock.json, followed by a fresh npm installation, but the issue persists. Any suggestions would be greatly appreciated. Scr ...

Connect an HTML file containing altered information

I am facing a simple question, but struggling to find the right search results due to my inability to articulate it effectively. My problem lies in how my website displays plain HTML files within a styled "mother" page. For instance, on https://mywebsite. ...

What could be causing the text-end to fail in Bootstrap 5?

Why can't I align the text to the right? Feeling frustrated as a beginner. <div class="top-bar"> <div class="container"> <div class="col-12 text-end"> <p><a href="tel:06 ...

Revamped React Navigation Version 4

Currently, I am in the process of developing a web application using React and incorporating React Router v4 for navigation purposes. My main goal is to redirect to a new page upon successful completion of the signup process (when the user signs up). Do yo ...

Obtaining a string from a regular expression does not function as anticipated

Currently, I am in the midst of a project that requires me to identify specific HTML tags and replace them with others. To accomplish this task, I am utilizing JavaScript, and the code snippet looks like this: // html to update html = '<div cla ...

Using JQuery to attach an onclick event to multiple links that share the same class

There are links on the website with the ".tel" class <a class='tel' href="http://example.com">Link</a> To add an onclick event to all these links, follow these steps onclick="return gtag_report_conversion('http:// ...

Utilize the v-if directive with nested object properties for dynamic conditional rendering

I need to verify if the item object has a property called 'url' set. If it's not present, I would like to display a placeholder image. Here is an example of what I want to achieve: <img v-if="item.relationships.main ...

Use the angular cli to incorporate the CSS styles found in the node_modules directory

After successfully installing a new library with npm, I now face the challenge of importing the CSS into my project. It seems unwise to directly link to the node_modules folder. Can anyone suggest an easy way to import this CSS into my Angular CLI project? ...

Date discrepancy detected on AWS EBS server; however, it is operating seamlessly on the local environment

Whenever deployed on an AWS server, there seems to be a recurring miscalculation. Background: All dates stored in my MongoDB are in UTC format. I need them converted to IST before exporting them to Excel. While my code functions flawlessly on my local m ...

Avoid using reduce in JavaScript

I'm attempting to extract specific values from an object with the status of 'xyz' user.friends = CoreMongooseArray [ { _id: 5b11824350c0011afe9ca310, user: { profile: [Object], _id: 5b11805a50c0011afe9ca2fe, username: 'user1&apo ...

Hiding elements in FireBase and Angular based on user identification

Currently venturing into the world of Firebase in conjunction with AngularJS after previously working with php and server-side rendered pages. I am grappling with how to securely hide specific parts of an application from certain users. I have three disti ...

Optimizing Content Display for Android Screens

Although I have successfully optimized my site for OS and iOS, testing it on Android devices using browserstack.com has presented a challenge when it comes to targeting them with media queries. This is the query that I currently use for iOS devices: #uti ...

Keeping track of user sessions

I am in need of a solution where users can only be logged in with their ID on a single machine. My initial idea was to use a flag in the database indicating if the user is currently logged in (isLoggedIn = true or false). This way, when a user tries to log ...

Exploring face detection with Three.js

When I utilize an octree, I am able to generate an array of faces that are in close proximity to an object. However, I am unsure how to perform a ray cast to these faces. All the resources I have found only explain how to ray cast to a mesh, line or poin ...

Creating a seamless rotation effect on an SVG shape at its center across all browsers, even Internet Explorer

Is there a way to make an SVG figure rotate around its center? I have been trying to calculate the rotation center and scale it based on the viewBox. It seems to work perfectly fine in Chrome, Firefox, and Safari, but I just can't seem to get it to wo ...

How can I pass a hidden value to my script using jQuery?

Using a combination of ASP.NET MVC and jQuery, I have an icon that triggers a dialog box when clicked. The code in Reports.cshtml: <a class="dialog-opener" href="#"> <input type="hidden" name="reportID" value="@view.ReportCode"/> < ...

Issue with Saving Modal in Bootstrap 5: Button Does Not Function

I've been following the instructions on , but I'm facing an issue with getting the save button to work on my modal. Initially, I tried placing it within the form tag, but it ended up using the form action from the main view instead of the partial ...

Retrieve the dimensions of a document using only the URL link

Currently, I am working with vb.net and jquery. A specific issue has arisen during my work process. With the help of jQuery, I am loading various URL links to different documents within an iframe using the following code: document.getElementById('iFr ...

The Countdown feature is currently only functioning on the initial button and not on any of the other buttons

I could use some assistance. I have a download button with a countdown, but there seems to be an issue with the button's functionality. It only works on the first button, or if the second button is clicked first, it starts the countdown on the first b ...

nanoExpress Route Isolation

I am facing an issue while trying to separate route directories in my project. The error I encountered is as follows: rror [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cjs' is not defined by "exports" in /mnt/.../projects/.../nan ...