Enhancing usability by incorporating relevant dropdown options into the Bootstrap navbar

Utilizing the Animated Bootstrap Navbar Dropdown from startbootstrap.com has presented a challenge. When attempting to incorporate a secondary menu option labeled "Interests" with dropdown items such as "Sport" and "Travel", an unexpected issue arises. The Curriculum Vitae dropdown menu seems to override the desired "Interests" selection. As someone who is new to Bootstrap, I suspect that there may be a mistake in how the code is arranged. Any guidance or assistance on this matter would be greatly appreciated.

/* Adjust this breakpoint if you modify the navbar's breakpoint */

@media (min-width: 992px) {
  .animate {
    animation-duration: 0.5s;
    -webkit-animation-duration: 0.5s;
    animation-fill-mode: both;
    -webkit-animation-fill-mode: both;
  }
}

@keyframes slideIn {
  0% {
    transform: translateY(1rem);
    opacity: 0;
  }

  100% {
    transform: translateY(0rem);
    opacity: 1;
  }

  0% {
    transform: translateY(1rem);
    opacity: 0;
  }
}

@-webkit-keyframes slideIn {
  0% {
    -webkit-transform: transform;
    -webkit-opacity: 0;
  }

  100% {
    -webkit-transform: translateY(0);
    -webkit-opacity: 1;
  }

  0% {
    -webkit-transform: translateY(1rem);
    -webkit-opacity: 0;
  }
}

.slideIn {
  -webkit-animation-name: slideIn;
  animation-name: slideIn;
}

/* Additional page styles unrelated to the animated dropdown */

body {
  background: #007bff;
  background: linear-gradient(to right, #0062E6, #33AEFF);
}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container">
    <a class="navbar-brand" href="#">Síofra Kelleher</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Curriculum Vitae
        </a>
        <div class="dropdown-menu dropdown-menu-right animate slideIn" aria-labelledby="navbarDropdown">
            <a class="dropdown-item" href="#">About Me</a>
            <a class="dropdown-item" href="#">Experience</a>
            <a class="dropdown-item" href="#">Education</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Contact Me</a>
          </div>
          
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          My Interests
        </a>
          <div class="dropdown-menu dropdown-menu-right animate slideIn" aria-labelledby="navbarDropdown">
            <a class="dropdown-item" href="#">Sports</a>
            <a class="dropdown-item" href="#">Travel</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="#">Contact Me</a>
          </div>
        
          <!-- Utilize the .animate and .slide-in classes within your .dropdown-menu for seamless integration -->
          
        </li>
      </ul>
    </div>
  </div>
</nav>

<div class="container text-center">
  <h1 class="mt-5 text-white font-weight-light">Síofra Kelleher's IS1113 Web Development Project</h1>
  <p class="lead text-white-50">Insert some pretty words here</p>
</div>

Answer №1

Separate the second Dropdown into its own li tag:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container">
        <a class="navbar-brand" href="#">Síofra Kelleher</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        Curriculum Vitae
                    </a>
                    <div class="dropdown-menu dropdown-menu-right animate slideIn" aria-labelledby="navbarDropdown1">
                        <a class="dropdown-item" href="#">About Me</a>
                        <a class="dropdown-item" href="#">Experience</a>
                        <a class="dropdown-item" href="#">Education</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="#">Contact Me</a>
                    </div>



                    <!-- Add .animate and .slide-in classes to your .dropdown-menu for a nice animation effect -->

                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        My Interests
                    </a>
                    <div class="dropdown-menu dropdown-menu-right animate slideIn" aria-labelledby="navbarDropdown2">
                        <a class="dropdown-item" href="#">Sports</a>
                        <a class="dropdown-item" href="#">Travel</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="#">Contact Me</a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</nav>

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

Dividing the Row in Bootstrap4 into two columns

I'm trying to figure out how to split a row into two sections to accommodate two headings in a single row, similar to the following: https://i.sstatic.net/GD99P.png Unfortunately, my current code isn't allowing me to separate the row as shown ab ...

What is the best way to trigger a function in Jquery if an email is deemed valid, and another function if it is considered invalid?

I'm trying to create an email input field and a button that, when a valid email is entered, will open a successful registration pop-up with some added style. However, if the email input is empty or invalid, I want to display an error pop-up instead. T ...

Expanded MUI collapsible table squeezed into a single cell

I'm experimenting with using the MUI table along with Collapse to expand and collapse rows. However, I've noticed that when utilizing collapse, the expanded rows get squished into one cell. How can I adjust the alignment of the cells within the p ...

transforming the elements within a div into a visual representation

I'm in the process of developing a web-based image editor. My main div will have multiple nested div elements within it. My goal is to save the entire main div as an image in a designated folder when the user clicks on a save button. I initially atte ...

Is it possible to refresh a table that is currently displayed in a model popup?

My code to reload a table or div inside a model popup continuously is not working as expected. Can you help me with this issue? I attempted to utilize ajax for this purpose but unfortunately, the code below is not updating chats (I am working on a chat ta ...

Configuring a Revolution Slider 5+ layer to display as a fixed layer

I wish to keep a consistent shape below my text on all the slides without any flickering. Although Revolution Slider offers static layers, they always appear on top and cannot be layered beneath other slide layers. I attempted to create a layer with no t ...

Integrate a fresh component and include a hyperlink to the URL simultaneously

Seeking to create a system where clicking an item in the navbar loads a new component on the screen, I am faced with the challenge of maintaining state while also updating the URL. Allow me to provide more details: Below is my current navbar code snippet: ...

The button I've designed can't be clicked directly on the text or icon, but rather around them

I'm facing an issue with a button that has an icon and text below it. The clickable area is only around the icon and text, not on them. https://i.sstatic.net/55FWF.png scss file .navbar { background-color: #292929; height: 70px; } .button { di ...

What is the best way to determine the accurate size of a div's content?

There are 2 blocks, and the first one has a click handler that assigns the block's scrollWidth to its width property. There is no padding or borders, but when the property is assigned, one word wraps to the next line. The issue seems to be that scrol ...

An object dispatches the form to the server

In my form, I have implemented form checking to detect errors and ensure that it is valid before submitting it to the server. However, I have encountered a problem where even after detecting errors, the form is still being sent to the server when it should ...

What is the best way to place an icon in the lower right corner of a design

I have encountered an issue while building the testimonial section below. The problem arises when the amount of text in each block is not the same, causing the quote icon to be displayed improperly in the bottom right corner. Sometimes, it even extends out ...

What is the best way to print out multiple objects using console.log?

I am working on a JavaScript exercise where I want to create a function that produces an icon output using FontAwesome. While I have managed to display the icon and message, I am struggling to incorporate my custom styles for titles, emphasis, etc., using ...

Vertically align the text

Is there a way to center this text vertically within the divs? I've attempted adjusting the position using relative/absolute, and modifying the top and left properties of the paragraph, but none of these methods have been successful. div.roxo{ ...

Modify the color with JavaScript by manipulating the Document Object Model (DOM)

const elementBox = document.getElementsByClassName('box'); let colorAsStringVariable = '#FEC6F0'; let colorAsNumberVariable = #FEC6F0; Array.from(elementBox).forEach((element) =>{ element.style.backgroundColor = colorAs ...

Looking to transform basic HTML into a bitmap or image effortlessly?

For my project, I have a database containing several simple HTML texts such as: <ul>this is apple</ul> <ul>this is orange</ul> <p>I want to <u>eat</u> apple</p> hello <i>mr</i> orange In this pr ...

"Enhance your website with a dynamic animated background using Bootstrap container

I'm struggling to understand why the Bootstrap container is blocking the particles-js animation behind the text. I want the background surrounding the text to be animated as well... :/ Example Code: .gradient-bg { background: rgba(120, 87, 158, ...

Tips for showing form data upon click without refreshing the webpage

Whenever I input data into the form and click on the calculate button, the result does not appear in the salary slip box at the bottom of the form. However, if I refresh the page and then click on the calculate button, the results are displayed correctly ...

Column-based Bootstrap dropdown menu

Is it possible to create a vertical dropdown menu with columns similar to the one featured on Microsoft's website, without the use of JavaScript? Check out the image for reference: https://i.sstatic.net/h7ftN.png ...

Issue with adding Django products to cart in a delayed manner

https://i.sstatic.net/uWwK3z7I.png[ The initial image depicts the add to cart button, which should trigger the addition of the product and display the cart modal with the added item upon clicking. The second image illustrates the expected outcome, but I ...

Unchecking random checkboxes within a div using jQuery after checking them all

Once a link is clicked on, all checkboxes within that particular div will be checked. function initSelectAll() { $("form").find("a.selectAll").click(function() { var cb = $(this).closest("div").find("input[type=checkbox]"); cb.not(":checked" ...