Accordion nested within a bootstrap 4 tabbed navigation bar

I recently started learning how to use Bootstrap and found it easy to create a webpage with easy navigation features.

As I was working on implementing an accordion inside a navbar for easier navigation, I encountered an issue. While the first tab and accordion function correctly, the others do not work properly when interacting with them.

In the first accordion, clicking on any card closes the others as expected. However, in the subsequent accordions, the cards remain displayed and I can't figure out what's causing this issue.

I double-checked the data-target, data-toggle, aria-labelledby attributes, and classes but couldn't pinpoint the problem. I suspect it might be due to the div structure, as I'm inserting a div with the accordion class in each tab-pane.

    <nav>
        <div class="nav nav-tabs" id="nav-tab" role="tablist">
            <a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home"
             aria-selected="true">1. Introduction</a>
            <a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile"
             aria-selected="false">2. Wet AMD Symptoms</a>
            <a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact"
             aria-selected="false">3. Risk Factors</a>
        </div>
    </nav>

    ...

If you want to take a closer look at my code, feel free to visit my fiddle link.

Answer №1

@git-e-up is right on point. It's essential to have unique identifiers for each accordion group. Here's an example:

<div class="accordion" id="accordion1">

Take a look at this updated Fiddle

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

Tips for customizing the cursor to avoid it reverting to the conventional scroll cursor when using the middle click

When you wish to navigate by scrolling with the middle mouse button instead of using the scroll wheel, simply middle-click and your cursor will change allowing for easy scrolling on web pages. Even though I am utilizing style="cursor: pointer" and @click. ...

Is it possible to apply a background color to a specific text div without affecting the rest of the elements on the page

I am currently facing an issue with a navigation div that is positioned at the top of my page. The div, which consists entirely of text, functions properly. However, when I scroll over an image or text on the page, the content inside the div becomes diffic ...

How many logical lines of code are in the Ubuntu operating system?

As I develop my web application, it is crucial for me to track the lines of code written in languages such as php, css, html, and JavaScript specific to the /var/www directory. However, when using the command line code counter tool, I find myself tempted ...

Conceal the menu in Angular Material when the mouse leaves the button

When the mouse hovers over a button, a menu is displayed on the website's toolbar. The menu is set to close when the mouse leaves a surrounding span element. Now, there is an attempt to also close the menu when the mouse leaves the triggering button i ...

Tips for vertically centering a span within a div that is floated to the right

Need help centering a span vertically within a div when using float:right? <div class="card"> <div class="card-header"> <h5>TEST</h5> <span class="fa fa-info"></span> </div> <div class="card-body" ...

IE11 causing issues with CSS 3D animation playback

My experience with this animation in IE11 is not what I expected. I thought it would open like a book. This animation was made using Google Web Designer (I've kept the code short for simplicity). If you want to see how it looks in IE11, click here: ...

If the image is not found, deactivate the anchor or hyperlink

I am encountering an issue where I have an image tag within an anchor element setup as shown below: <a href='$image'><img alt='No Image' src='$image'></a> When the image is not available, I can still intera ...

When you hover, there is no writing cursor in sight

I'm looking for a way to display a label on an input field and have a writing cursor show up when hovering over the label. I am not interested in using a placeholder label. Do you have any simple solutions for this? See the code snippet below: JSFiddl ...

ExternalInterface.call in as3 leading to crashes in web browsers

I have a webpage with HTML and JavaScript that successfully hides and displays a flash movie object. However, I encounter a problem when trying to exit from the tab - the browser crashes without any error message. Can anyone provide assistance? Thank you. ...

Unable to change Gutters to 0 in the .container-fluid class in Bootstrap 5.2

I have gone through all the answers related to my question, but I couldn't find a solution for it. Below is the HTML code with Bootstrap 5.2 that I am working on: <section id="title"> <div class="container-fluid"> ...

Create beautiful HTML forms with Laravel Collective Forms in Laravel 5.7

I am currently using the Laravel Collective form code shown below: {!! Form::open(['action' => ['CategoryController@sub8', $item1->id], 'method' => 'post']) !!} {{Form::label('postaladdress', &apos ...

There is a lag in the loading of css stylesheets

We created a single-page company website that utilizes three different stylesheets connected to the index.html. By clicking a button, users can switch between these stylesheets resulting in changes to colors, images, and text colors. However, Issue 1: The ...

Tips for modifying the property value of a navigation bar in Bootstrap using Sass

I currently have a navigation bar on my webpage that is styled with the following CSS properties: .navbar { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 0.5rem 1r ...

Having issues with jQuery Checkbox Selector and .attr('checked) function not functioning correctly?

I'm trying to assign the value of a variable as true or false based on the selected checkbox. However, the code I have is not working as expected. <input type="checkbox" id="chkBox1"> var chkBox1Val = $('#chkBox1').prop('checked ...

Align your text box perfectly with Bootstrap Glyphicons

https://i.sstatic.net/G2qVu.pngI am struggling with incorporating a glyphicon next to my text box in the following HTML code: <div class="row"> <div class="col-md-6"> <div class="form-group"> <asp:Label runat="server ...

How to enable seeking functionality for mp3 files with PHP

I have implemented the following PHP script: video tags are unable to extract metadata from it. Any insights on where I might be going wrong and how to rectify this situation? Your guidance would be greatly appreciated. Thank you.</p> ...

Is there a way to submit a form without displaying the values in the URL?

For quite some time, I've been attempting to solve this issue, but none of the answers I've found seem to apply to my specific situation. The front end of my webapp consists of a very simple HTML page. It features two forms - one for creating an ...

Tips for concealing text adjustments during window resizing in an HTML document

I'm currently working with a website code that involves two sidenavs, one on the right and another on the left. When one sidebar opens, the other collapses. However, I've noticed that the text in between readjusts when the sidebars are toggled op ...

Strategies for delivering CSS exclusively to up-to-date browsers

What are some methods for serving CSS exclusively to modern browsers while displaying plain, unstyled HTML to outdated versions of Internet Explorer? I am currently employing the following approach, but I am not particularly thrilled about having my main ...

Changing the Class of a Child Element When Clicking on an Accordion Panel

I am having trouble finding a way to toggle the css class of a span tag within my Ajax Accordion header. The goal is to change the class of the span tag in the header based on whether the header is selected or not, switching between a plus icon and a minu ...