How can you switch alignment from left to right when the current alignment settings are not functioning as expected in HTML?

I need the buttons +, count, and - to be right-aligned on my page. The numbers on the right are taking up the same amount of space, while the names on the left vary in length. I want the buttons to always remain in the same position, regardless of the name lengths. I've tried adding margin-right, padding-right, and aligning to the right in the style of the first div, but nothing seems to work as the buttons remain in their original position.

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

html:

<div>
        <li class="list-group-item d-flex justify-content-between lh-sm">
            <h6 class="my-0" style="size: 10px;">{{ item.name }}</h6>
            <div>
                <a class="fab-button red bg-success" style=" float:right;">
                    <div class="plus"></div>
                </a>
                <a style="float:right; size: 20px; padding-right: 2mm; padding-left: 2mm;">
                    <strong>{{count}}</strong>
                </a>
                <a class="fab-button red bg-success" style=" float:right;">
                    <div class="minus"></div>
                </a>
            </div>
            <span class="text-muted">
                {{ item.price }} zł
            </span>
        </li>
    </div>
    

css:

.fab-button {
        border-radius: 50%;
        display: table;
    }

    .fab-button div {
        background:  rgb(0, 0, 0);
        margin: 11px;
    }

    .fab-button .plus {
        width: 4px;
        height: 4px;
        box-shadow: 0 0 rgb(0, 0, 0), 0 -3px rgb(0, 0, 0), 0 3px rgb(0, 0, 0), -3px 0 rgb(0, 0, 0), 3px 0 rgb(0, 0, 0), 0 -6px rgb(0, 0, 0), 0 6px rgb(0, 0, 0), -6px 0 rgb(0, 0, 0), 6px 0 rgb(0, 0, 0);
    }
  
    .fab-button .minus {
        width: 4px;
        height: 4px;
        box-shadow: 0 0 rgb(0, 0, 0), -3px 0 rgb(0, 0, 0), 3px 0 rgb(0, 0, 0), -6px 0 rgb(0, 0, 0), 6px 0 rgb(0, 0, 0);
    }

Answer №1

It appears that you are utilizing bootstrap. If the based value has a fixed size, consider wrapping the counter and value with this tag

<div class="d-flex justify-content-end">

<li class="list-group-item d-flex justify-content-between lh-sm">
  <h6 class="my-0" style="size: 10px;">ssssadaasdsadsadssadsd</h6>
    <div class="d-flex justify-content-end">
      <div class="mx-2">
        <a class="fab-button red bg-success" style=" float:right;">
          <div class="plus"></div>
        </a>
        <a style="float:right; size: 20px; padding-right: 2mm; padding-left: 2mm;">
        <strong>1</strong>
        </a>
        <a class="fab-button red bg-success" style=" float:right;">
          <div class="minus"></div>
        </a>
      </div>
      <span class="text-muted">
         454545 zł
      </span>
  </div>
</li>

Explore live example here

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

Oops! An error occurred: Uncaught promise rejection - invalid link found for ProductListComponent

I am currently in the process of learning Angular and Ionic, but I am feeling a bit confused as to where my mistake is. I have looked at other questions, but I still can't seem to figure it out. Can anyone provide some assistance? Perhaps someone has ...

How can JQuery determine the current CSS background image of a three-state icon or button?

I am facing a challenge with using three images to represent different states of an application icon, and I am trying to achieve this using CSS. There are no issues with the original or hover states: #myDIV { background-image: url(icons/homeBlack.png); } ...

"The custom input component still displays a required error message even after all fields have been filled

After implementing the ControlValueAccessor interface to create a custom input component and setting the required property to true for form validation, I am facing an issue where the input field still shows a "required" error even when it is filled. The mo ...

Comparing Django forms to conventional forms

As I work on my Django website, I find myself torn between utilizing Django-Forms and sticking with the traditional hand-coded HTML forms. While HTML forms offer certain benefits that align with my needs, I must admit that I have also experienced advanta ...

Does Angular Material2 support a column class of col-md-4 or something similar?

Lately, I've been exploring the world of Angular 2 and Material design. Previously, I was using PrimeNG but decided to switch to Angular Material. However, I'm having trouble finding the classes for changing widths like col-md-4, etc. It seems t ...

I'm seeking assistance in enhancing this code within tb for extracting values using JavaScript

Currently, I am extracting values from a table using JavaScript. The code seems to be functioning correctly, but I am looking for ways to optimize it and ensure that it is compatible with most modern browsers. The list in the table undergoes frequent chang ...

Contrasting the utilization of percentage width in relative vs fixed contexts

I am facing an issue with the sizing of two div elements on my page, one with relative positioning and the other with fixed positioning. <div class="outer1"> </div> <div class="outer2"> </div> Here is the CSS: .outer1{ width: ...

Angular 2 module that is loaded lazily - service does not follow singleton pattern

After successfully implementing lazy loading modules into my application, I have ensured that the app.module.ts is properly configured. @NgModule({ declarations: [ AppComponent, HeaderComponent, HomeComponent ], imports: [ BrowserMod ...

Angular NgFor directive for rendering data

Is it possible to showcase information from a selected *ngFor on another page? For instance, I have two pages: result.component.html and details.component.html result.component displays data using *ngFor while details.component showcases the details of th ...

Arranging pictures in both vertical and horizontal alignment (CSS)

I've been attempting various methods to solve this issue, but none have proven successful. My goal is quite simple: align images both horizontally and vertically in a manner that fills empty spaces with photos. Similar to the layout here: The challe ...

The webpage failed to show the hamburger menu

I'm trying to create a hamburger menu and have written the following code: <header class="header"> <nav class="flex flex-jc-sb flex-ai-c"> <a href="/" class="header__logo"> <img src="im ...

Why do identical elements show different scrollHeights when overflowed and how can this discrepancy be resolved?

I am using a plugin that generates a <p> element and continuously fills it with the content from a <textarea>. This plugin positions the <p> directly below the <textarea>, and styles them so that they appear identical in terms of th ...

Implementing CSS to Style Images in JavaFX FXML

After creating the FXML structure below, I attempted to define a border in CSS for the Image by using code in the customerform.css file: <VBox id="customerFormPane" styleClass="customerForm" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.exampl ...

Is it possible to use velocity js to add a gradient color effect to text content?

Can I use velocity js to apply gradient color to text? I've looked at https://css-tricks.com/snippets/css/gradient-text/ My specific need is to dynamically add a changing gradient using js. Thank you in advance. ...

What is the best way to notify the user if the percentage entered is not a numeric value?

My role is to notify the user when the entered value exceeds the acceptable range: if (document.myForm.outputPercentage.value <= 0 || document.myForm.outputPercentage.value >= 100) { alert( "Please enter a percentage between 1 and 100 ...

How do I verify if a boolean variable has been changed within an Angular service?

In my MatHorizontalStepper parent component, I utilize the subscribe function to monitor changes in an Observable within a service. The purpose is to automatically progress to the next step in the stepper when the observable switches from false to true. D ...

Is there a way to allow scrolling in only one direction using CSS?

I am facing an issue with resizing elements within a list. The requirement is that when the elements are resized, they should overflow the container only in the x direction. There must not be any scrolling in the x direction, but scrolling should be allowe ...

What is the process for loading this image?

While browsing through this stunning website, I came across a feature that caught my eye. Can someone please explain how the designer displayed the "The magic is loading" effect: The image vanishes once the site has finished loading completely. ...

Media queries for Tailwind CSS in a Node JS application do not function properly when viewed on a mobile device

I recently developed a Node JS app using EJS templates and Tailwind CSS. Check it out live here: If you're curious, feel free to explore the code on Github. While the media queries function well on desktop devices, they seem to be ineffective on mo ...

Why isn't my axios login get request functioning as expected?

I am currently working on a login-page for a school project. I am using vue.js and have been attempting to make a get-request using axios. However, I am facing an issue where I cannot even enter the .then() block as the last thing displayed is alert(TEST1) ...