Arranging elements in a row and column to ensure proper alignment

https://i.stack.imgur.com/LMsTg.png

I'm having trouble aligning the UI elements in my Bootstrap 5 project. I can't seem to pinpoint the issue despite trying various solutions. Here's the code snippet:

<div class="container"> 
    <div class="accordion accordion-flush" id="accordionFlush">
        @forelse($indicators As $indicator)
        <div class="accordion-item">
            <h2 class="accordion-header" id="flush-headingOne{{$indicator->id}}">
              <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne{{$indicator->id}}" aria-expanded="false" aria-controls="flush-collapseOne{{$indicator->id}}">
                <div class="row align-items-center">
                    <div class="col-1 m-0">
                        <div class="p-2" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="fa-solid fa-ellipsis-vertical "></i>
                        </div>
                        <ul class="dropdown-menu dropdown-menu-dark">
                            <li><a class="dropdown-item" href=""><i class="fa-solid fa-plus"></i> Add Sub Indicator</a></li>
                            <li><a class="dropdown-item" href="/edit_indicator/{{$indicator->id}}"><i class="fa-solid fa-pen-to-square"></i> Edit</a></li>
                            <li><a class="dropdown-item" href="{{ route('delete_indicator', ['id' => $indicator->id]) }}"><i class="fa-solid fa-trash "></i> Delete</a></li>
                        </ul>
                    </div>
                    <div class="col-sm-2">
                        {{$indicator->indicator_name}}
                    </div>
                    <div class="col-8">
                        {{$indicator->indicator_desc}}
                    </div>
                </div>
              </button>
            </h2>
            <div id="flush-collapseOne{{$indicator->id}}" class="accordion-collapse collapse" aria-labelledby="flush-headingOne{{$indicator->id}}" data-bs-parent="#accordionFlush">
                <div class="accordion-body">
                Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.
                </div>
            </div>
          </div>
        @empty
             No Data yet
        @endforelse
    </div>
</div>

Answer №1

It appears that you are looking to properly align the elements within each accordion item. Since you are utilizing Bootstrap 5, it's important to ensure that the elements are structured correctly and that the Bootstrap classes are applied appropriately. Here is an enhanced version of your code with some improvements for better alignment:

<div class="container"> 
    <div class="accordion" id="accordionFlush">
        @forelse($indicators as $indicator)
            <div class="accordion-item">
                <h2 class="accordion-header" id="flush-headingOne{{$indicator->id}}">
                    <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne{{$indicator->id}}" aria-expanded="false" aria-controls="flush-collapseOne{{$indicator->id}}">
                        <div class="row align-items-center">
                            <div class="col-1">
                                <div class="dropdown">
                                    <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton{{$indicator->id}}" data-bs-toggle="dropdown" aria-expanded="false">
                                        <i class="fa-solid fa-ellipsis-vertical"></i>
                                    </button>
                                    <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton{{$indicator->id}}">
                                        <li><a class="dropdown-item" href="#"><i class="fa-solid fa-plus"></i> Add Sub Indicator</a></li>
                                        <li><a class="dropdown-item" href="/edit_indicator/{{$indicator->id}}"><i class="fa-solid fa-pen-to-square"></i> Edit</a></li>
                                        <li><a class="dropdown-item" href="{{ route('delete_indicator', ['id' => $indicator->id]) }}"><i class="fa-solid fa-trash"></i> Delete</a></li>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-sm-2">
                                {{$indicator->indicator_name}}
                            </div>
                            <div class="col-8">
                                {{$indicator->indicator_desc}}
                            </div>
                        </div>
                    </button>
                </h2>
                <div id="flush-collapseOne{{$indicator->id}}" class="accordion-collapse collapse" aria-labelledby="flush-headingOne{{$indicator->id}}" data-bs-parent="#accordionFlush">
                    <div class="accordion-body">
                        Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item's accordion body.
                    </div>
                </div>
            </div>
        @empty
            No Data yet
        @endforelse
    </div>
</div>

Changes made and reasons behind them:

  1. The accordion-flush class was removed from the accordion container as it is unnecessary for alignment purposes.

  2. Bootstrap classes (btn btn-secondary) were added to the dropdown button for proper styling and alignment.

  3. The dropdown button and menu were enclosed in a div with the class dropdown for correct dropdown functionality.

With these modifications, the UI elements should align correctly within each accordion item. Ensure that you have included Bootstrap CSS and JavaScript correctly in your project for Bootstrap to function as expected.

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

Enhancing the appearance of buttons with hover effects in Twitter Bootstrap

I am interested in customizing the hover button styling for Bootstrap v3.2. The default behavior is to darken on hover, but I would like to make it lighter instead. Although I checked the Buttons Less variables, I couldn't find an option specifically ...

Creating a horizontal layout for list items that are responsive using CSS

My website has a "Featured" section with 3 equally sized elements displayed horizontally. I want to make the webpage responsive by using percentage widths, but when I resize the window to less than the list width, the items stack on top of each other. Che ...

Troubleshoot padding problems in mpdf

Note: mpdf 6.0 Greetings, In my efforts to produce precise PDFs using mpdf for future printing purposes, I have encountered an issue with the positioning of elements on the page. I require these elements to be positioned precisely from the top left corne ...

issues with padding in the main content section

When I try to search for something that isn't on the page, a strange margin or padding issue occurs. I have thoroughly reviewed the code but can't seem to pinpoint the problem. The unwanted 30pxish margin after the footer should not be present wi ...

React Hamburger Menu not working as intended

I am facing an issue with my responsive hamburger menu. It is not functioning correctly when clicked on. The menu should display the navigation links and switch icons upon clicking, but it does neither. When I remove the line "{open && NavLink ...

Displaying text on an image when hovering over it

I have tried various solutions that I came across, but none of them have been successful so far. My goal is to display dynamic text over an image when the user hovers over it. Additionally, I would like to change the hover color. Currently, the text is alw ...

CSS Problem with Image Overlapping

Attached is an image that I would like to design in HTML. It has been quite successful, but when testing it on different resolutions, the red box seems to move around. The design was created with 100% width and height. <style type="text/css"> ...

Show brief tags all on one line

This image showcases the functionality of the site, specifically in the "Enter a code" column where users can input data using TagsInput. I am seeking to enhance this feature by ensuring that shorter tags are displayed on a single line. While I am aware th ...

The mobile menu toggle functionality is malfunctioning on actual mobile devices, however, it is operational when tested on various mobile sim

Recently, I noticed that on , the menu collapses into a hamburger icon for mobile. However, when tapping on it on my phone and other devices, nothing happens. Surprisingly, it works perfectly fine when clicking on it in mobile simulators within Google Chro ...

What could be causing the malfunction of my Superfish menu in Firefox?

I am currently experimenting with the Superfish jQuery plugin to improve a drop-down menu on my website. Unfortunately, in Firefox browser (v. 21.0), the drop-down menu does not open when hovering over it as expected. However, it works fine in Chrome and O ...

Determine the height of the left div, which is set to auto, and apply the same height to the right div, which has overflow set

I am facing an issue that needs a solution. I need to ensure that two div elements have the same height. The left div should have 'auto' height while the right one must match it. Moreover, the right div contains 14 nested divs that need to be scr ...

What is the method for changing the icon color to dark in Twitter Bootstrap?

I am facing an issue where the icon in my menu tab turns white when active, making it difficult to see. Is there a way to change the color of the icon to black? I have found a class icon-white to make it white, but there is no corresponding class to make ...

Tips for aligning numbers in a monospaced ordered list

Is there a way to align the numbers in a numbered list within a table using monospace font so that they are at the same level as bullets on a bullet list? Simplest example: ol { font-family: monospace; } ul, ol { margin-top: 10px; margin-bottom: ...

Is there a way for me to modify this carousel so that it only stops when a user hovers over one of the boxes?

I am currently working to modify some existing code to fit my website concept. One aspect I am struggling with is how to make the 'pause' function activate only when a user hovers over one of the li items, preventing the carousel from looping end ...

jQuery Super-sized Not Expanding Vertically

I am facing an issue with resizing a 1920x1200 background image using jQuery Supersized. Whenever I resize the browser, there is a gap that appears vertically instead of filling up to compensate for the width constraint. I have checked and copied the sett ...

IE11 experiencing issues with font loading

I need help troubleshooting why the fonts are not loading properly in the body section of my articles, specifically when viewed in Internet Explorer. Take a look at an example article here: I am fetching from this CSS file: , and I have included the nece ...

I need some assistance, please. Can someone explain why the Bootstrap card is staying aligned to the left in mobile view

I've tried everything, but it's still not working. Can anyone help me out? Here are some photos. BEFORE AFTER When I view the card on mobile, I want it to stay centered. Could there be some missing code that I'm overlooking? I would great ...

The specified selector is invalid or illegal in HTMLUnit

Attempting to mimic a login using htmlunit has presented me with an issue despite following examples. The console messages I have gathered are as follows: runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' erro ...

Is there a way to randomly change the colors of divs for a variable amount of time?

I have a unique idea for creating a dynamic four-square box that changes colors at random every time a button is clicked. The twist is, I want the colors to cycle randomly for up to 5 seconds before 3 out of 4 squares turn black and one square stops on a r ...

Align two tables horizontally in the center using HTML

Is there a way to center two tables side by side using CSS? I have been able to center a single table, but I am struggling to center two tables together. Can anyone provide a simple solution using CSS? Below are the codes I have used: @import url(ht ...