Use ngFor to align items to the left in your design

I am working on a div element where I need to dynamically add inputs that should form a number with a specific format. To ensure the inputs start from the left, I have applied the justify-content-end class. HTML:

<div class='row justify-content-end'>
  <ng-container *ngFor='let input of dashAndInputCount; let i = index'>
     <button (click)='addDashAndInput(i)'> - </button>
     <div class='col-2' style='padding-top: 2.2rem !important;'>
        <input type='number'></input>
     </div>
     <div class='col-1 ax-text-center'>
        <p>
          ــ
        </p>
     </div>
  </ng-container>
</div>

TS:

  addDashAndInput(i) {
    this.dashAndInputCount.push(1);
  }

However, I encountered an issue where the items are added in the wrong direction. For example, adding 1, 2, 3, 4 results in them displaying as 4, 3, 2, 1. How can I resolve this problem?

Answer №1

The justify-content Property relies on the presence of display: flex. Make sure to include display: flex in the class called justify-content-end

.justify-content-end{
   display: flex;
   justify-content: end;
}

Answer №2

To create a flexible layout, make sure to add the d-flex class to your container. This will enable the element to act like a block element and organize its content based on the flexbox model.

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 access the selectedIndex and handle click events for select options in Angular4

Initially, my aim was to get the selectedIndex and then retrieve the selected data model, but I discovered that I could directly access the selected data model in Angular2 RC2 by following this link: Angular2 RC2 Select Option selectedIndex. However, I e ...

Stingray Riverbed SteelApp, showcasing an image on a maintenance landing page

We have implemented a feature on riverbed stingray that displays a maintenance page whenever the system administrator needs to update the application. In order to achieve this, we designed a custom HTML page with a logo image and uploaded both the .html an ...

Hide the background when the modal appears

I have successfully implemented a jQuery CustomBox modal on my website. However, I am facing an issue with hiding the content div behind the modal once it pops up. My goal is to make the content div reappear after the modal has been closed. You can view a ...

Removing the 'div' tag using jQuery in CodeIgniter

I need assistance in removing the added item. $(document).ready(function() { $("#appendex0").click(function() { $(".divcls0").append('<div class="col-sm-10 col-sm-offset-1"><div class="col-sm-3 col-sm-offset-1"><div class="form ...

What are the steps to effectively utilize my search bar alongside Google Custom Search?

Here is the HTML code for my form: <form action="#" class="searh-holder"> <input name="se" id="se" type="text" class="search" placeholder="Search.." value="" /> <button class="search-submit" id="submit_btn"><i class="fa fa-sea ...

Tips for ensuring that each flexbox element fills up a single line

My goal is to have each child element fill up one line by itself. See this screenshot for reference: https://i.stack.imgur.com/F40Xm.png Below is the code I am currently using: main { display: flex; justify-content: space-around; align-items: ...

Content sliding to the left due to modal prompt

I've searched through various questions and answers but haven't been able to resolve this issue. There's a modal on my page that is causing the content to shift slightly to the left. I've created a sample fiddle, although it doesn&apo ...

Is it possible to verify the presence of an ID with jQuery?

Is it possible to check for the existence of the id 'input-name' before assigning a value to the variable name using a line of code similar to this: var name = $('#input-name').attr("value"); In case the id 'input-name' does ...

The issue of the color CSS rule not being applied to the button element when transitioning from disabled to enabled on browsers like Safari 14+ is a common challenge

There seems to be an issue with frontend form validation code affecting the disabled attribute of a submit button within a form. Two different css rules are applied for the enabled and disabled states, including changes in the text color of the button ele ...

updating rows in a table

Currently, I have a grid array filled with default data retrieved from the database. This data is then displayed on the front end in a table/grid format allowing users to add and delete rows. When a row is added, I only want to insert an empty object. The ...

Is it possible to switch between Jquery and CSS?

Using PHP, I have created a CSS file that enables me to easily adjust the color of various elements. Is there a way for me to regenerate the stylesheet and apply it to the DOM using JQuery? For example: <?php if (isset($_POST['mycolor'])){ $ ...

The choice always seems to gravitate towards the initial option without any clear explanation

echo "<td>Language</td>"; echo "<td><select id='language' name='language'> <option value=''>Select...</option> <option value='en_US'>English(US)</o ...

"Integrating Laravel 5.4 Backend with Angular 5 Frontend: A Step-by-Step

Currently, I am immersed in a project that involves creating a frontend using Angular 5 and backend business logic using Laravel 5.4 with MySQL Database. As someone new to this technology stack, I find myself grappling with establishing the data flow conne ...

Outer div encapsulating inner div within its boundaries

I am looking for a solution where the inner div stays fully contained within the outer div, without overflowing and overlapping with the padding of the outer div. Here is a code sample that demonstrates the issue .inner { /* Overflow */ overflow-wra ...

The GitHub Pages website is not displaying exactly like it does when running locally with a live server

Currently in the process of creating a compact website where users can input an anagram and receive all potential words that can be formed from it. Additionally, upon receiving these words, there is an option to click on one for its definitions. The site ...

How can I enable the "Open in a new tab" functionality while utilizing ng-click?

I've encountered an issue with my HTML table where each row is supposed to link to a different page, providing more detailed information. However, because I am using angularjs and utilizing ng-click on the rows, I am unable to right-click and select & ...

Angular 2 - The creation of cyclic dependencies is not allowed

Utilizing a custom XHRBackend class to globally capture 401 errors, I have encountered a dependency chain issue in my code. The hierarchy is as follows: Http -> customXHRBackend -> AuthService -> Http. How can this problem be resolved? export cla ...

Adjust the transparency of a `<ul>` element as it descends on the webpage - CSS3

I have a list (<ul>) that I would like to fade out as it scrolls down the page. I attempted to use linear-gradient, but I was unsuccessful. Is this even possible? You can view an example of what I am trying to achieve on JSFiddle here: http://jsfidd ...

The CSS Validator does not recognize the CSS pointer-events and appearance properties

I'm a CSS beginner who recently created an app. I've encountered some errors and warnings when validating my CSS code: https://i.stack.imgur.com/g4MUz.png https://i.stack.imgur.com/Es1DE.png Could someone kindly explain these errors and warnin ...

Wrapping Text around an Image in HTML

I am currently in the process of designing a website using the flexible box model. My main challenge right now is trying to align text to the right of an image, and then below it. I've attempted using float:right/left along with align="left/right", bu ...