Arrange list items in alignment without the need for additional CSS (bootstrap) styling

<div class="card-body p-0">
   <ul class="list-group list-group-flush">
      <li class="list-group-item d-flex justify-content-between" th:each="extraConfig : ${extraConfigsPage.content}">
         <div>
            <a class="item-link">
              <span class="item-name ml-2" th:text="${extraConfig.description}"></span>
            </a>
         </div>
         <div>
            <a class="btn btn-outline-danger" data-toggle="modal" data-target="#deleteReportModal">
              <i class="fas fa-trash-alt"></i>
            </a>
         </div>
      </li>
   </ul>
</div>

After analyzing the code, I noticed that the first item in the list (the first div) is not aligned properly with the icon in the same row. My goal is to have the first item align completely left and centered within the row while having the second item align completely right and also be centered (currently only the second item is perfectly aligned).

I am determined to achieve this alignment using only bootstrap classes without adding any extra CSS. Any suggestions or solutions would be greatly appreciated. Thank you for your help!

Answer №1

To align the icon with the center of your left-side tag, consider adding the bootstrap class align-baseline to your anchor tag for the icon:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d7f7272696e696f7c6d5d29332b332d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f1d10100b0c0b0b1e0f3f4b5149514f">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>

<div class="card-body p-0">
    <ul class="list-group list-group-flush">
        <li class="list-group-item d-flex justify-content-between">
            <div>
                <a class="item-link">
                    <span class="item-name ml-2">Fling</span>
                </a>
            </div>
            <div>
                <a class="btn btn-outline-danger align-baseline" data-toggle="modal" data-target="#deleteReportModal">
                    <i class="fas fa-trash-alt"></i>
                </a>
            </div>
        </li>
    </ul>
</div>

I made adjustments to the code so that the icon is centered by using the align-baseline class. A descender word was also added for comparison.

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

Enhance Your Website with HTML and JavaScript

Here is the code snippet I am working with: sTAT **javascript** var acc = document.getElementsByClassName("item-wrapper"); var i; for (i = 0; i < acc.length; i++) { acc[i].onclick = function(){ this.classList.toggle("selected"); this.nextElementS ...

retrieve the domXPath value from the HTML document

Can anyone help me with extracting the content of the <span id="the_name"> tag from my HTML code? Here is a snippet of the HTML: ... <span id="userName" class="username"></span> <div class="main"> <div class="menu"> & ...

What is the best way to change a SCSS hexadecimal value into a string for usage as a CSS class name?

My SCSS file contains numerous variables like: $blue: #007bff !default; $indigo: #6610f2 !default; $purple: #6f42c1 !default; $pink: #e83e8c !default; $red: #dc3545 !default; I am wondering if it is possible to convert the value of $blue to a ...

Tips on removing the red border from a text box within an HTML form with the help of AngularJS

My form has the following appearance: https://i.stack.imgur.com/T3NQW.png Upon clicking the submit button, the textbox fields display a red border due to the required attribute. Afterwards, I aim to click the reset button in order to remove the red bord ...

Achieving a 100% height sidebar that remains visible on the screen at all times in Bootstrap

Looking to achieve this specific layout: I want the left col-md-3 to maintain a consistent 100% height and always be visible on the screen - it's going to be a menu. The right side should function normally with scrolling capabilities. Appreciate any ...

Tips for pressing the enter key to submit when faced with two buttons

I am developing a form with two input fields and their respective submit buttons. I want users to be able to enter text into either field, hit the Enter key, and have it trigger the same action as clicking the submit button. Currently, pressing Enter after ...

Ways to expand the height of a child element within a flex container that has been

I am facing an issue with stretching the children of a column flexbox container. While I can stretch one of the flexbox child elements, I am unable to stretch its nested children. Below is an example where .flex-child-2-child and .flex-child-2-child-child ...

Unable to view Bootstrap modal upon click

Whenever I attempt to display a modal using Bootstrap, it mysteriously appears upon page refresh but fails to show up when the button is clicked. Ideally, I want the modal to only appear when the user clicks on the button. The structure of my html file lo ...

Side navigation in Angular is not causing the main content to shrink

In my layout, I have a container that includes two sidenavs and multiple tables in between them. When I toggle the left sidenav, instead of the expected behavior where the content shrinks to accommodate the sidenav, the tables get pushed to the right as if ...

Discovering the initial element with a data attribute above zero using JQuery

I am working with a set of divs that have the class .item-wrap. At the moment, I am able to select the first div using this code snippet: $(".item-wrap:first").trigger( "click" ); Each .item-wrap element comes with a data-amount attribute. My challenge ...

The Enigmatic Gap Amidst Flex Elements

I have a situation where two divs are placed within a flex container. However, the second div is incorrectly aligning to the right side of the page rather than next to the first div. Despite the default values for flex-flow being row and justify-content b ...

Searching and replacing query strings in a URL using JQuery according to the chosen option in an HTML dropdown menu

Is there a way to use jQuery to dynamically change a specific value in the query string by finding and replacing that value based on the selection made from a dropdown menu on the webpage? For example: Imagine we have this query string on the current page ...

Is there a way to prevent HTML code from being executed when sharing it as text? I want to be able to share code without it being activated as HTML on the page

Seems like I have a straightforward issue related to HTML tags. I am looking to post some code snippets on my blog, specifically the <h1> heading</h1>. I want visitors to view and not just the bolded text of heading. Do I need to incorporate J ...

Is it possible to extract form data from a div tag based on its class name?

I'm working with some code that looks like this: var iconContainer = document.getElementById('iconContainer'); var icon = iconContainer.getElementsByClassName("item"); for (var i = 0; i < icon.length; i++) { icon[i].addEventListener ...

The Canvas drawn using JavaScript is not being resized and painted correctly on Safari mobile and Firefox mobile browsers

I created an HTML page that features a canvas element where I am drawing a roulette using JavaScript After checking the CanIuse website, I learned that canvas functionality is supported in Firefox 68 and Safari 4 to 13 <!DOCTYPE html> <html> ...

The HTML and body elements do not possess a width of 100% within the document

When viewing my portfolio site on smaller screens such as 425px and below, there is a white gap on the right side. This issue arises because the HTML and body elements do not inherit full width by default. Do you know why this happens and how I can resol ...

What is the best approach for creating a single jQuery click function to manage multiple elements within a slider?

Here's my query: I have a slider on my website where each slider item consists of an image and a Bandcamp iframe link. Below is an example code of one of the slider items: <div class="tapecol col-md-4"> <img class="media-ob ...

Customize React Bootstrap Slider Attributes on the Fly

Is it possible to dynamically set attributes for the React Bootstrap Slider control available at https://github.com/brownieboy/react-bootstrap-slider? For instance, can the control be disabled after the slideStop event? ...

Move the first column to the right using BS4

Currently, I am working with bootstrap4 and facing an issue where I need the first div column to float right on medium devices and above. However, on mobile devices, it should be shown first. This was easily achievable in bootstrap3 using a structure lik ...

Use jQuery to place the initial 3 elements within a div

Currently, I am dynamically pulling content into li elements using ASP.NET. My goal is to wrap a specific div class around the first 3 li items in the list only. Here is an example: <ul class="wrapper"> <div cl ...