Tips for arranging CSS Cards in the right sequence (Horizontal, not Vertical)

Just starting to learn Angular and currently working on organizing cards in a bootstrap css layout.

Here is the current order of the cards:

  • A F
  • B G
  • C H
  • D I
  • E J

When I resize the page to test responsiveness on a phone screen, the order corrects itself to A-J.

However, I would like the cards to be displayed in this order when in a two-column view:

  • A B
  • C D
  • E F
  • G H
  • I J

I have tried solutions from various sources such as this answer and examples from this page, but so far my layout remains unchanged.

This is the code snippet I am currently using:

 <div class="card-columns mt-1 mb-5">
    <div class="card" *ngFor="let group of form.formGroup">
        <!-- <div class="card"> -->
        <div class="card-header">
            <h5 class="text-uppercase">
                {{group.title}}
                <span class="float-right">
                    <i class="fas fa-edit text-primary" (click)="open(content,group)"></i>
                </span>
            </h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-sm-12" *ngFor="let control of group.fields">
                    <label class="text-uppercase"><strong>{{control.label}}</strong></label>
                    <div>
                       <button type="button" class="btn btn-lg btn-primary" disabled>{{datapersonal[control.model_property]}}</button>
                       <br><br>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

My issue is not misalignment of the cards, but rather their display order which is not as desired.

Answer №1

The main div is currently using the card-columns class, which is causing the elements to be displayed in a certain order. If you remove this class, the elements will be ordered as expected.

<div class="mt-1 mb-5">
    <div class="card" *ngFor="let group of form.formGroup">
        <!-- <div class="card"> -->
        <div class="card-header">
            <h5 class="text-uppercase">
                {{group.title}}
                <span class="float-right">
                    <i class="fas fa-edit text-primary" (click)="open(content,group)"></i>
                </span>
            </h5>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-sm-12 col-lg-6" *ngFor="let control of group.fields">
                    <label class="text-uppercase"><strong>{{control.label}}</strong></label>
                    <div>
                       <button type="button" class="btn btn-lg btn-primary" disabled>{{datapersonal[control.model_property]}}</button>
                       <br><br>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

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

Implementing additional input with Jquery causes tooltips to malfunction

I am developing a form that allows users to add as many rows as needed. Each input is being treated as an array for easy data storage in the database, which is a new concept for me. $(document).ready(function() { var maxField = 10; //Limitati ...

Angular version 6 allows for specifying input types as numbers and displaying two decimal digits after the comma

How can I format user input to display as currency with thousand separators in Angular? <input type="number" (ngModelChange)="calculateSum()" (change)="calculateAmount(invoiceQuota)" [ngModel]="invoiceQuota.controls.grossAmount.value"> I have attem ...

Display the column every time the user types something into the search bar

Currently working on an Angular project and I'm trying to figure out how to make the middle column visible whenever the user enters text in the search bar. At the moment, I have a search bar for user input and three flex columns. The middle column is ...

Setting up the php/MVC framework on a server

Currently, I have developed a project using HTML/PHP and need guidance on uploading it to the server. My knowledge of servers is limited, but I do understand that the first page should be an index.php or index.htm file placed in the public_html folder. How ...

Optimizing background images for various mobile devices using PhoneGap

Currently in the process of creating a cross-platform app for iOS and Android using Phonegap. Facing an issue with implementing a background-image as it gets cropped or distorted on various mobile devices due to size differences. Managed to address this ...

Hide the selection box when hovering over the Div

Looking for a quick solution. I want the option drop down to close when another div element is hovered over. First, open the drop down and hover over the red element on the right side. When hovering over the red element, I would like the drop down to clos ...

Understanding how to set a specific tab based on the URL in a jQuery tab script

How can I modify my jQuery search script to ensure that only the type is considered when a URL is created with #type/query/? Even if there is a query included in the URL, I want the corresponding tab to appear selected. Can someone help me understand how t ...

Ways to activate auto completion without using a string

Can anyone assist us with the tinymce editor? We have implemented an auto completion feature using a plugin from TinyMCE's documentation, but we are having trouble changing the triggering behavior. Currently, it only suggests options when "@" is typed ...

Is there a way to detect duplicate usernames in a form without actually submitting the form, and then automatically focus on the username field if a duplicate is

I need help with a user registration form that I am creating. I want the form to automatically search for an existing username as soon as the user starts typing in the username field. If the username already exists, I want the field to receive focus. In my ...

establish the parent child size with CSS

In my current project, I am faced with a challenge regarding the CSS and HTML code. I am attempting to have a <div> element positioned after an <img> element inherit the width and height of the image. This <div> is meant to act as an over ...

The next/prev buttons on the carousel and scrolling functionality are malfunctioning

The Bootstrap Carousel component is not functioning as expected. It does not scroll automatically and the next/prev buttons are not working. Despite checking the order of Jquery/Bootstrap dependencies and using the carousel code from the Bootstrap document ...

Animating borders with jQuery

Attempting to add animation to a button click using borders and jQuery animate function. jQuery( '#sendForm' ).hover( function (){ jQuery( this ).animate({ borderTopWidth: "5px", borderBottomWidth: "0px" }, 'fast&apo ...

Tips for merging two classes in CSS

Within my code, I have two classes named classA and classB. I am looking to have classB inherit the style of classA while still only using classB. .classA{ width:100px;} .classB{ height:100px;} <div class="classB"></div> ...

The React style background property for CSS styling

Is there a way to apply the css property background inline in react? I attempted to pass the following object without success: let style = { background: `linear-gradient( rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6) ...

Tips for incorporating HTML code within a select option value?

I am working with AngularJS to create a Visual Composer for a website. One feature I want to incorporate is the ability to add HTML code based on the selection made in a dropdown menu. However, I am struggling to figure out how to include the HTML within t ...

CSS styles not displaying correctly - malfunctioning (unusual)

Trying to tackle this issue, but feeling a bit lost. Whenever I resize the site below 1600px, everything breaks despite having media queries in place to handle the changes. One particular problem that's baffling me is related to a logo in an id that s ...

employing animation and iterating through each one for dynamic effect

Javascript $(document).ready(function() { $(".container").animate({left:'120px'}, 6000).queue(function(next){ $(".child").css('display', 'none'); }); }); The provided code snippet demonstrates animating a single box and t ...

What are the implications of storing data in the id attribute of an HTML element?

If I have a template where I need to loop and generate multiple div elements, each containing a button, how can I listen to clicks on these buttons individually? <div class="repeatedDiv"> <button class="reply-button"> </div> $(&apos ...

Can you provide me with information on how to indicate the activated menu item by highlighting the triggering button in Angular 14 and Material Design?

Is there a way to highlight the triggering button in an Angular Material menu, while also highlighting a menu item that matches a routerLink? <button mat-button [matMenuTriggerFor]="animals">Animal index</button> <mat-menu #animals ...

Place objects at the bottom of the screen

I'm currently using Bootstrap 4 and facing an issue where I want to keep a row with some columns at the bottom of the page. However, when I add position fixed and set it to bottom, the placement gets disrupted and does not stay centered. I suspect thi ...