Tips for showcasing div content on a separate line rather than inline within a collapsible <a> tag

I am currently working on integrating a sidebar using bootstrap 5.

When I click on the user initials, I want something like this to happen (collapse):

https://i.sstatic.net/ejbhD.png

However, the result I'm getting is different:

https://i.sstatic.net/gUejA.png

I suspect it has to do with the d-flex class, as I have looked at multiple questions on SO without finding a solution.

Is there a way to separate the content into two blocks and insert a breakline between them instead of setting up two columns?

Check out the JS FIDDLE LIVE DEMO

Here is the relevant portion of the code:

<ul class="list-unstyled components">
                <li class="nav-item">
                    <a class="btn btn-primary d-flex" data-toggle="collapse" href="#sidebarUserProfile" role="button" aria-expanded="false" aria-controls="sidebarUserProfile">
                        <div class="row">
                            <span class="userInitials">JW</span>
                            <div class="d-flex text flex-row align-items-center staff-nav-holder">
                                <div class="d-flex flex-column">
                                    <span class="staff-name fw-bold">John Walker</span>
                                    <span class="staff-position">PM</span>
                                </div>
                                <i id="profile-chevron-down" class="bi bi-chevron-down ml-2">
                                </i>
                            </div>
                        </div>
                        <div class="row">
                            <div class="collapse d-block" id="sidebarUserProfile">
                            <ul class="list-unstyled components">
                                <li>Customize your homepage</li>
                                <li>Change your password</li>
                                <li>Log out</li>
                            </ul>
                            </div>
                        </div>
                    </a>
                    </p>
                </li>
            ...
           </ul>

Answer №1

This issue arises when the "d-block" class is used in a collapsed item. A collapsed item should not have a 'd-block' class because it signifies: 'display: block;' This goes against the following rule:

.collapse:not(.show) {
    display: none;
}

For reference, check out this pen: https://codepen.io/witty_code/pen/zYdwbZW

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

How to reposition the Bootstrap navbar Logo from the left to the center

I am looking to change the ordering of Bootstrap 4 Navbar. Currently, the logo is on the left side, but I want it in the center with menus on both sides. Can someone help me with changing this order? Check out the current Navbar layout below: <nav c ...

Ways to adjust a column width to be equal to the full width

My HTML table has columns with fixed widths, except for one that I want to expand to fill the remaining space with a minimum width set. I attempted using width: auto, but it didn't achieve the desired result of filling the leftover space. ...

To keep the PHP echo statement inline with the HTML code, simply use the following syntax

(<?php _e( 'Up to', 'test' ); ?> &pound;<?php $current_price = get_field( 'price_details_price_b', 'option' ); $exchange_rate = get_field( 'price_details_exchange_rate', 'option' ); ...

Exploring for JSON keys to find corresponding objects in an array and adding them to the table

I'm currently working on a project where I need to extract specific objects from a JSON based on an array and then display this data in a table. Here's how my situation looks: playerIDs: number[] = [ 1000, 1002, 1004 ] The JSON data that I am t ...

What steps can I take to minimize the excessive white space below the footer on my website?

I have been attempting to resolve this issue by using multiple methods, but none of them have successfully fixed it. overflow-x: hidden; min-height: 100%; margin: 0px; https://i.sstatic.net/2ctwo.jpg Code: body: background-color: White; margin: 0px; p ...

yet another problem with overflow-x being hidden while overflow-y is visible

I am currently working on creating a tab overflow user interface that is similar to what Firefox uses. This involves utilizing a combination of fixed width containers and a fluid width container in the middle to hold the tabs. The challenge arises when th ...

What is the best way to transform this unfamiliar CSS element into JavaScript code?

I'm facing an issue where I want to animate a CSS image based on time constraints, but since it's in CSS, I'm unable to achieve the desired effect. The animation in question is not the sun itself, but rather a yellowish half-circle animation ...

Fade out one div and then fade in a new one using Jquery

Hey there! I'm looking to create a smooth transition effect for my website where the content fades out when clicking on a menu item, and then fades in with the new content based on the link provided. Here's an example: . So basically, when I clic ...

Is there a way to prevent javascript from automatically inserting tags when selecting text?

If you want to view the Fiddle Here Essentially, it's a text-highlighting tool that works almost flawlessly. The problem arises when it encounters tags like <p> or <br> within the selection. The JavaScript code seems to automatically in ...

Is it possible to convert (HTML and CSS3 generated content for paged media) into a PDF format?

Would it be possible to convert a HTML document styled with CSS3 Generated Content for Paged Media into a PDF format? If such an application does not exist, what alternatives can I consider as the foundation for developing a converter? Thank you ...

Submitting with enter key on typeahead suggestions

Seeking guidance on Bootstrap typeahead: how can I configure it to submit the entered text upon pressing the enter key? Specifically, if I type "hello" in the typeahead input and hit enter, how can I submit "hello"? I've successfully disabled the aut ...

What is the best way to place an icon in the center of a Bootstrap 5 card image?

I'm looking to center an icon within a bootstrap-5 card image. I have an icon that I want to display at the center of my card image, but I'm unsure how to achieve this using either CSS or Bootstrap-5. Can anyone provide guidance on how to accompl ...

Refreshing PHP Script

I have a PHP file that contains a combination of HTML elements, JavaScript functions, and PHP scripts. I need to rerun a specific part of the PHP script repeatedly. Let's consider the following example: <html> <?php $connection = ...

Conceal the scroll bar within a div set to 100% viewport

Having some difficulty with a scrollbar on my new portfolio. The layout consists of two columns, with content on the left. I need the ability to scroll without displaying the scrollbar. I attempted the code below but it did not work. Could the issue be rel ...

Attempting to align the dropdown menu to the left side

This is a challenge I'm facing: https://i.sstatic.net/d3PtN.png I'm attempting to align it in the following way: https://i.sstatic.net/GCwEO.png Below is the HTML code snippet: <li class='list-group-item'> <!-- The dropdow ...

Is there a way to eliminate the table-hover effect on specific rows in the table?

Here is some HTML: <table class="table table-striped table-bordered table-condensed table-hover"> .... </tr> <tr ng-repeat-end ng-show="modelRow.activeRow==car.name" class="hidden-table"> <td colspan="6"> ...

Attempting to align text around an image within Bootstrap 4

I'm struggling to wrap text around my image at approximately 1355px. I attempted using float-left on both the div container and the img tag, but nothing seems to be working. Could it be due to the column setup I have in place? Should I perhaps add an ...

By default, Nuxt 2.15.7 is automatically installed when you create a new Nuxt app

I am looking to develop a Nuxt app (version 3) using Vue. However, when I run the command npm create nuxt-app@version mousa, it automatically installs Nuxt2. How can I install Nuxt3 instead with this command? ...

Control Over Fluid Grid Layouts

Apologies for reaching out, as I usually try to figure things out on my own. However, after spending hours reading through countless pages with no success, I am at my wit's end. I'm struggling to create a 4-column 'home' landing page f ...

JQuery is not able to render Hindi content properly

I am attempting to showcase some Hindi words using JQuery because these are essential contents that need to be displayed on every page of the website. Please note that this is a static website built with HTML and JQuery/JavaScript. Below is my JS file: in ...