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

Tips for evenly distributing list elements in HTML without using whitespace

After reading the article on flexbox techniques without actually using flexbox, I attempted to implement "space-between" in my code: ul { margin: 0; padding: 0; text-align: justify; } ul:after { content: ""; display:inline-block; width:100%; ...

Creating consistent image placement across all divs: a step-by-step guide

html { font-family: 'Open Sans', sans-serif; } body {margin: 0; padding: 0; } #wrapper { padding-left:50px; padding-top:30px; } #third, fifth { background-color:#E8E8E8 ; } img[src^="my_menu.png"] { z-index:10; } #s ...

Half-extended Bootstrap 4 container reaching the edge of the page

I'm looking to create a layout with a .container that consists of two distinct halves. The left half should function as a standard .col-6, while the right half should extend all the way to the edge of the screen, similar to a .col-6 within a .contain ...

Guide on jQuery: Concealing the scrollbar on the body

Is there a way to hide the scroll bar using Jquery? I tried this code for Chrome but need a solution that works for all browsers. $ ::-webkit-scrollbar { display: none; } Any suggestions on how to achieve this cross-browser compatibility? ...

Achieving opacity solely on the background within a div class can be accomplished by utilizing CSS properties such

Whenever I adjust the opacity of my main-body div class, it results in all elements within also becoming transparent. Ideally, I would like only the gray background to have opacity. See below for the code snippet: <div class="main1"> content </di ...

CSS overflow property does not take effect when set to hidden

I'm having trouble understanding why the overflow: hidden property is being overridden by a descendant element. Take a look at this example I've put together http://jsfiddle.net/2fRxc/. HTML <div class="relative"> <div class="overf ...

Tips for incorporating several d3 elements on a single webpage

I am currently facing an issue where I am attempting to add a line graph below a d3 map, but the map and line graph are appearing below where the map should be located. I have tried creating separate div tags with distinct id's, but I am unsure of wha ...

Should I use CSS, Bootstrap, or a combination of both for a complicated design in a React app

I am currently developing a react app and utilizing react-bootstrap to incorporate various components. As someone who is new to javascript, react, and web development as a whole, I find it challenging at times. My goal was to create a layout that seemed q ...

Discover the ultimate guide to harmonize IE 9 with the ingenious Bootstrap Multiselect plugin developed by davidstutz

I've come across an amazing plug-in developed by David Stutz that allows for a Bootstrap and jQuery multi-select options list. Here are some resources: Check out the source code on Github Find documentation and examples here This plug-in works fla ...

Using Laravel and Bootstrap v4, you can easily implement a feature that redirects to a specific tab after

I have a webpage featuring 3 tabs. I am trying to set up the page so that it redirects to the same tab that was active before the reload. I assume each tab should append a string to the URL, like #menu1 or #menu2, but I'm having trouble implementing t ...

Tips on altering hover effects?

I am having trouble changing the font size and color of the a when hovering over p. I have been trying to figure this out for a while now, but I can't seem to get it to work. If anyone has any simple links related to this topic, I would greatly appre ...

CSS - Curved background image in the top left corner

Currently in the process of creating a website here. There is a postcode search div on the right side, and I am looking to round the top corner of it. I have decided to use images to achieve the rounded corners effect. My requirement is that any method us ...

What is the process for setting an AMP-video as a full-page background?

My homepage features a captivating hero video in the background, but I've encountered an issue where the AMP video does not scale properly to fit the screen on mobile devices. Here's the code snippet causing the problem: <amp-v ...

Incorporating a hamburger symbol into an established menu for easy navigation

I have come across a tutorial on creating a navigation menu with a logo positioned to the left. However, I now wish to incorporate a hamburger icon for mobile devices and I am unsure about the process. Despite my efforts to find a suitable tutorial onlin ...

Changing the names of the validation messages in Laravel

Currently, I am developing the backend of my project using Laravel. One of the requirements is to validate both a password field and its confirmation field. To achieve this, I have implemented the following validation rules: $rules = [ 'password& ...

Unable to disable background color for droppable element

For my project, I am working with two div boxes. My goal is to make it so that when I drag and drop box002 into another div box001, the background color of box001 should change to none. I have attempted to achieve this functionality using jQuery without s ...

Tips for maintaining the footer at the bottom of the page regardless of the screen size

In my current project, I am dealing with several web pages. For each page, I have arranged three div tags: Header Body (content) Footer The issue arises when it comes to the body div tag, which houses the main content of a page such as forms and descrip ...

Challenges with Adjusting Background Opacity in CSS

My text has a white background with an opacity of .3, but it's affecting the foreground due to CSS repositioning. Even though the HTML is in a different division, I struggle with certain aspects of CSS and would appreciate guidance from those more exp ...

Move a div by dragging and dropping it without creating duplicates

I'm in need of some assistance. It seems like a simple task, but I'm having trouble finding a solution. I've managed to create draggable elements that work smoothly without any issues. The drag and drop functionality is working perfectly. ...

styling a flex container with aligned text and buttons

I'm attempting to align text on the left and button controls on the right within a display: flex div. <CustomFieldContainer> <StyledWellContainer> <FieldDetails key={id}> <H4 bold>{label}</H4> <Styled ...